On Monday 20 October 2008 04:36:58 pm Andreas Bühmann wrote:
> Denys Vlasenko wrote:
> > BTW, I reproduced what you see. It's a simple matter of getopt()
> > state not being reset.
> >
> > Please try attached patch, does it help you?
> >
>
> Not really (apart from making my test case work); it seems to break the
> command-line version of getopt completely:
>
> # getopt -o ab -- -a -b -c
> --
> # getopt -l foo,bar -- --foo --bar --baz
> --
I was too optimistic with removing stuff,
getopt.c heeds getopt() reset for entirely different reason.
Please try with this patch on top:
--
vda
Index: util-linux/getopt.c
===================================================================
--- util-linux/getopt.c (revision 23733)
+++ util-linux/getopt.c (working copy)
@@ -157,6 +157,14 @@
if (quiet_errors) /* No error reporting from getopt(3) */
opterr = 0;
+ /* We used it already in getopt32(), we *must* reset getopt(3) */
+#ifdef __GLIBC__
+ optind = 0;
+#else /* BSD style */
+ optind = 1;
+ /* optreset = 1; */
+#endif
+
while (1) {
opt =
#if ENABLE_GETOPT_LONG
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox