Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: List of unresolved issues (update)
- X-seq: zsh-workers 11057
- From: Peter Stephenson <pws@xxxxxxxxxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxx (Zsh hackers list)
- Subject: Re: List of unresolved issues (update)
- Date: Tue, 02 May 2000 10:50:52 +0100
- In-reply-to: "Your message of Mon, 01 May 2000 05:21:27 -0000." <1000501052127.ZM8590@xxxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
> Of those, I think 9095 is the only really crucial one. The others might
> warrant mention on the BUGS list or some such.
The bug was this:
function oops {
while getopts :m: f
do
echo $OPTIND is $f with $OPTARG
shift $((OPTIND - 1))
done
print -r - $*
}
% oops -m 664
2 is m with 664
2 is ? with k
funky
(Note that the apparently correct display of `funky' is a coincidence, it
comes from incorrectly shifting by 2-1 twice.)
The fix looks easy, which in this particular chunk of code makes me very
suspicious (see the comment). However, I'll commit it anyway until we find
the drawback. We need comprehensive tests for getopts, including nested
functions, asap.
I now get:
% oops -m 664 funky
3 is m with 664
funky
% oops -m664 funky
2 is m with 664
funky
which I think is right.
Index: Src/builtin.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v
retrieving revision 1.10
diff -u -r1.10 builtin.c
--- Src/builtin.c 2000/04/30 14:48:49 1.10
+++ Src/builtin.c 2000/05/02 09:47:05
@@ -3077,7 +3077,15 @@
p = ztrdup(args[zoptind++]);
} else
p = metafy(str+optcind, lenstr-optcind, META_DUP);
- optcind = ztrlen(args[zoptind - 1]);
+ /*
+ * Careful: I've just changed the following two lines from
+ * optcind = ztrlen(args[zoptind - 1]);
+ * and it's a rigorous theorem that every change in getopts breaks
+ * something. See zsh-workers/9095 for the bug fixed here.
+ * PWS 2000/05/02
+ */
+ optcind = 0;
+ zoptind++;
zsfree(zoptarg);
zoptarg = p;
} else {
--
Peter Stephenson <pws@xxxxxxxxxxxxxxxxxxxxxxxxx>
Cambridge Silicon Radio, Unit 300, Science Park, Milton Road,
Cambridge, CB4 0XL, UK Tel: +44 (0)1223 392070
Messages sorted by:
Reverse Date,
Date,
Thread,
Author