From: "Bart Schaefer" <schaefer@candle.brasslantern.com>
To: zsh-workers@sunsite.auc.dk
Subject: Re: "getopts" bugs and bad interactions with "shift"
Date: Tue, 23 Nov 1999 21:40:38 +0000 [thread overview]
Message-ID: <991123214038.ZM29906@candle.brasslantern.com> (raw)
In-Reply-To: <19991123182219.A7795@thelonious.new.ox.ac.uk>
On Nov 23, 6:22pm, Adam Spiers wrote:
> Subject: Re: "getopts" bugs and bad interactions with "shift"
> Bart Schaefer (schaefer@candle.brasslantern.com) 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
}
next prev parent reply other threads:[~1999-11-23 21:40 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-11-23 18:08 Bart Schaefer
1999-11-23 18:22 ` Adam Spiers
1999-11-23 21:40 ` Bart Schaefer [this message]
1999-11-23 22:17 ` zsh 3.0.7 hogs memory James Kirkpatrick
1999-11-24 5:35 ` Bart Schaefer
1999-11-24 16:25 ` James Kirkpatrick
1999-11-30 15:42 ` James Kirkpatrick
1999-11-30 16:03 ` Bart Schaefer
1999-11-23 20:36 ` "getopts" bugs and bad interactions with "shift" Zefram
1999-11-24 11:50 Sven Wischnowsky
1999-11-24 17:44 ` Bart Schaefer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=991123214038.ZM29906@candle.brasslantern.com \
--to=schaefer@candle.brasslantern.com \
--cc=zsh-workers@sunsite.auc.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).