zsh-users
 help / color / mirror / code / Atom feed
* How to yield an error with zparseopts when non-matching options are seen?
@ 2018-12-02 22:28 Peng Yu
  2018-12-03  0:13 ` dana
  0 siblings, 1 reply; 3+ messages in thread
From: Peng Yu @ 2018-12-02 22:28 UTC (permalink / raw)
  To: zsh-users

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-12-03  0:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-02 22:28 How to yield an error with zparseopts when non-matching options are seen? Peng Yu
2018-12-03  0:13 ` dana
2018-12-03  0:44   ` dana

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).