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?
- X-seq: zsh-users 23776
- From: Peng Yu <pengyu.ut@xxxxxxxxx>
- To: zsh-users <zsh-users@xxxxxxx>
- Subject: How to yield an error with zparseopts when non-matching options are seen?
- Date: Sun, 2 Dec 2018 16:28:29 -0600
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=i6ZpkEu1dOzyGq/B1nYJzuxAfrKwXSivVT+A2eNI0Fo=; b=qyWeJju064JsuQOr82qvdr/bB8gms1EGiQ0oVAQMmlpQ7kzuoz7WhJhlME1f0oWN6e RCOeSBseZpv4GzdSc17CeP+8exMK9IA7u0vzKNRpbQ/AtNJj80bS7JXyfN1yu65Ue9kf +N/5Dcb/UwGEBqlHcW/N2F+oo5jObGHEBTEgkKS1EmW/cOV5gTV1X8snvLlnZyy1OQRt WP8eAwgTJVxzxsRTgxffVt6O5c3J4xXA0qt09IziyxZ0lbfUGgb4nPl8+As23vbERoBS U2XHOcBwbWt1JHBTWvD52lXSHpd3ZpJ4fv5IGv1ZyTAvpO0qpCd58Qb4tAKSmfqgnQXU YWoQ==
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
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