Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: "getopts" bugs and bad interactions with "shift"
- X-seq: zsh-workers 8762
- From: "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxx
- Subject: Re: "getopts" bugs and bad interactions with "shift"
- Date: Tue, 23 Nov 1999 21:40:38 +0000
- In-reply-to: <19991123182219.A7795@xxxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
- References: <991123180832.ZM29676@xxxxxxxxxxxxxxxxxxxxxxx> <19991123182219.A7795@xxxxxxxxxxxxxxxxxxxxxxx>
On Nov 23, 6:22pm, Adam Spiers wrote:
> Subject: Re: "getopts" bugs and bad interactions with "shift"
> Bart Schaefer (schaefer@xxxxxxxxxxxxxxxxxxxxxxx) wrote:
> > Question: Is "getopts" based on some standard or emulated behavior of
> > some other shell, or is it strictly a zsh thing?
>
> getopt is part of GNU libc [...]
In case it wasn't obvious from Zefram's post, "getopts" != "getopt".
The GNU "getopt" command (short-args-only form) is very roughly equivalent
to
function getopt () {
optstr=":$1"; shift
got=()
ret=0
while getopts "$optstr" opt
do
if [[ $opt == [?] ]]
then
echo getopt: invalid option -- "$OPTARG" 1>&2
ret=1
else
got=("$got[@]" "-$opt" ${OPTARG:+"$OPTARG"})
fi
done
shift $OPTIND # $((OPTIND-1)) if 3.0.7 or before
echo "" "$got[@]" -- "$@"
return $ret
}
Messages sorted by:
Reverse Date,
Date,
Thread,
Author