From 304d5f9b3974f33c566b8e57bc1b79a99e9955d9 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Tue, 2 May 2000 09:56:09 +0000 Subject: [PATCH] 11057: getopts bug --- ChangeLog | 5 +++++ Src/builtin.c | 10 +++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 2e8697c81..58806c1db 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2000-05-02 Peter Stephenson + + * 11057: Src/builtin.c: getopts for options with arguments + miscounted $OPTIND and index into subsequent options (see 9095). + 2000-05-02 Sven Wischnowsky * 11053: Completion/Commands/_complete_help: always use empty diff --git a/Src/builtin.c b/Src/builtin.c index 79648561e..7e536756a 100644 --- a/Src/builtin.c +++ b/Src/builtin.c @@ -3077,7 +3077,15 @@ err: 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 {