zsh-workers
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@candle.brasslantern.com>
To: Peter Stephenson <pws@ifh.de>,
	zsh-workers@sunsite.auc.dk (Zsh hackers list)
Subject: Re: PATCH: 3.1.6-pws-3: more getopts bugs
Date: Fri, 10 Sep 1999 16:32:24 +0000	[thread overview]
Message-ID: <990910163224.ZM17291@candle.brasslantern.com> (raw)
In-Reply-To: <199909100921.LAA90878@hydra.ifh.de>

On Sep 10, 11:21am, Peter Stephenson wrote:
} Subject: PATCH: 3.1.6-pws-3: more getopts bugs
}
} 1. The counter for how far we are into a single option argument doesn't get
} rest when OPTIND goes back to 1 (i.e. when a new function is started), only
} if OPTIND is set explicitly to 0.  (How can this possibly have escaped
} notice for almost a decade?)

It went unnoticed because it was introduced in January of 1998 when Zefram
"Rewrote getopts to remove its various bugs."  (Or so says ChangeLog.)  It
is not present in 3.0.6 (try your "badfn" test case).

} 2. The manual page claims the option variable gets set to '?' even if an
} error message was printed by getopts itself (i.e. no initial colon).  Guess
} what?  To see that, remove the : and watch the second line not get
} executed.

This also works as expected in 3.0.6.  I wonder what bugs Zefram removed?

Anyway, as this works in 3.0.6 with optcind static to bin_getopts(), I
wonder whether saving/restoring optcind in exec.c is in fact the right
thing.  The diffs in bin_getopts() from 3.0.6 to 3.1.6 are so extensive
that I'm not immediately able to discern what's happening differently.
It looks like maybe the 3.0 code resets optcind before returning end of
options, whereas the 3.1 code sets it on entry to the function iff the
user has set OPTIND=0.

Restarting on OPTIND=0 must be one of the bugs Zefram fixed, but maybe
he shouldn't have taken out the reset of optcind upon failure return?


-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


  reply	other threads:[~1999-09-10 16:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-09-10  9:21 Peter Stephenson
1999-09-10 16:32 ` Bart Schaefer [this message]
1999-09-10 16:54   ` Zefram

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=990910163224.ZM17291@candle.brasslantern.com \
    --to=schaefer@candle.brasslantern.com \
    --cc=pws@ifh.de \
    --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).