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

How to yield an error with zparseopts when non-matching options are seen?



In the following example, -b has not been defined as an option, but
`zparseopts` return successfully. Is there a way to let it yield an
error when it sees such a case?

$  ./main.sh
set -- -b -a x -a y
zparseopts -D a:=bar
echo $?
0
declare -p bar
typeset -a bar=(  )
declare -p argv
typeset -a argv=( -b -a x -a y )

set -- -b -a x -a y
zparseopts -D -E a:=bar
declare -p bar
typeset -a bar=( -a y )
declare -p argv
typeset -a argv=( -b )
$ cat ./main.sh
#!/usr/bin/env zsh
# vim: set noexpandtab tabstop=2:

set -v
set -- -b -a x -a y
zparseopts -D a:=bar
echo $?
declare -p bar
declare -p argv

set -- -b -a x -a y
zparseopts -D -E a:=bar
declare -p bar
declare -p argv

-- 
Regards,
Peng



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