@@ -132,6 +132,7 @@ zle -N abbr_expand _zsh_abbr_expand_widget
132
132
133
133
function abbr() {
134
134
{
135
+ local abbr_number_opts=0
135
136
local abbr_opt_add=false
136
137
local abbr_opt_create_aliases=false
137
138
local abbr_opt_erase=false
@@ -341,7 +342,7 @@ function abbr() {
341
342
}
342
343
343
344
function abbr_error() {
344
- printf " abbr%s\\ nFor help run abbr -h \\ n" " $@ "
345
+ printf " abbr%s\\ nFor help run abbr --help \\ n" " $@ "
345
346
abbr_should_exit=true
346
347
}
347
348
@@ -472,57 +473,70 @@ function abbr() {
472
473
print " $abbr_usage \\ n"
473
474
}
474
475
475
- while getopts " :haerslpicgU" opt; do
476
+ local abbr_number_opts=0
477
+ for opt in " $@ " ; do
476
478
if $abbr_should_exit ; then
477
479
abbr_should_exit=false
478
480
return
479
481
fi
480
482
481
483
case " $opt " in
482
- h )
484
+ " -h " | " --help " )
483
485
abbr_usage
484
486
abbr_should_exit=true
485
487
;;
486
- a )
488
+ " -a " | " --add " )
487
489
abbr_check_options $abbr_opt_rename $abbr_opt_show $abbr_opt_list $abbr_opt_erase $abbr_opt_populate $abbr_opt_git_populate $abbr_opt_create_aliases
490
+ (( abbr_number_opts++ ))
488
491
abbr_opt_add=true
489
492
;;
490
- e )
493
+ " -e " | " --erase " )
491
494
abbr_check_options $abbr_opt_add $abbr_opt_rename $abbr_opt_show $abbr_opt_list $abbr_opt_populate $abbr_opt_git_populate $abbr_opt_create_aliases
495
+ (( abbr_number_opts++ ))
492
496
abbr_opt_erase=true
493
497
;;
494
- r )
498
+ " -r " | " --rename " )
495
499
abbr_check_options $abbr_opt_add $abbr_opt_show $abbr_opt_list $abbr_opt_erase $abbr_opt_populate $abbr_opt_git_populate $abbr_opt_create_aliases
500
+ (( abbr_number_opts++ ))
496
501
abbr_opt_rename=true
497
502
;;
498
- s )
503
+ " -s " | " --show " )
499
504
abbr_check_options $abbr_opt_add $abbr_opt_rename $abbr_opt_list $abbr_opt_erase $abbr_opt_populate $abbr_opt_git_populate $abbr_opt_create_aliases
505
+ (( abbr_number_opts++ ))
500
506
abbr_opt_show=true
501
507
;;
502
- l )
508
+ " -l " | " --list " )
503
509
abbr_check_options $abbr_opt_add $abbr_opt_rename $abbr_opt_show $abbr_opt_erase $abbr_opt_populate $abbr_opt_git_populate $abbr_opt_create_aliases
510
+ (( abbr_number_opts++ ))
504
511
abbr_opt_list=true
505
512
;;
506
- p )
513
+ " -p " | " --populate " )
507
514
abbr_check_options $abbr_opt_add $abbr_opt_rename $abbr_opt_show $abbr_opt_erase $abbr_opt_list $abbr_opt_git_populate $abbr_opt_create_aliases
515
+ (( abbr_number_opts++ ))
508
516
abbr_opt_populate=true
509
517
;;
510
- i )
518
+ " -i " | " --git-populate " )
511
519
abbr_check_options $abbr_opt_add $abbr_opt_rename $abbr_opt_show $abbr_opt_erase $abbr_opt_list $abbr_opt_populate $abbr_opt_create_aliases
520
+ (( abbr_number_opts++ ))
512
521
abbr_opt_git_populate=true
513
522
;;
514
- c )
523
+ " -c " | " --create-aliases " )
515
524
abbr_check_options $abbr_opt_add $abbr_opt_rename $abbr_opt_show $abbr_opt_erase $abbr_opt_list $abbr_opt_populate $abbr_opt_git_populate
525
+ (( abbr_number_opts++ ))
516
526
abbr_opt_create_aliases=true
517
527
;;
518
- g )
528
+ " -g " | " --global " )
519
529
abbr_check_options $abbr_opt_universal
530
+ (( abbr_number_opts++ ))
520
531
abbr_opt_global=true
521
532
;;
522
- U )
533
+ " -U " | " --universal " )
523
534
abbr_check_options $abbr_opt_global
535
+ (( abbr_number_opts++ ))
536
+ ;;
537
+ " -" * )
538
+ abbr_error " : Unknown option '$opt '"
524
539
;;
525
- * ) abbr_error " Unknown option '-$OPTARG '" ;;
526
540
esac
527
541
done
528
542
@@ -531,7 +545,7 @@ function abbr() {
531
545
return
532
546
fi
533
547
534
- shift $(( OPTIND - 1 ))
548
+ shift $abbr_number_opts
535
549
536
550
if ! $abbr_opt_global ; then
537
551
abbr_opt_universal=true
0 commit comments