Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Replacing getopts with zparseopts



Hi,

"From Bash to Z Shell" mentions that one could possibly use zparseopts 
instead of getopts - for instance to get long GNU style options ("--
long-option"). Unfortunately neither the book nor the man page were too 
helpful (my fault) in "translating" the standard option case.

Could someone help me to create the below simple construct with 
zparseopts and making sure that "-d" and "--debug", "-h" and "--help", 
and "-v" and "--verbose" refer to the same option?!

##
while getopts dhv opt
    do case $opt in
           (d)  setopt xtrace;;

           (h)  print_help
                exit;;

           (v)  print_version
                exit;;

           (\?) print_usage >&2
                exit 1;;
       esac
done
##

Thanks in advance,
Thorsten



Messages sorted by: Reverse Date, Date, Thread, Author