From: Peter Avalos Date: Sun, 25 Dec 2011 17:16:48 +0000 (-0800) Subject: sh: Allow unsetting OPTIND. X-Git-Tag: v3.0.0~297 X-Git-Url: https://gitweb.dragonflybsd.org/~nant/dragonfly.git/commitdiff_plain/45ae67c3f324b0f3f42e3fae90e6002e4a5b3bf5 sh: Allow unsetting OPTIND. Obtained-from: FreeBSD 227773 --- diff --git a/bin/sh/options.c b/bin/sh/options.c index 69dbfc5bb0..b3cb35293b 100644 --- a/bin/sh/options.c +++ b/bin/sh/options.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)options.c 8.2 (Berkeley) 5/4/95 - * $FreeBSD: src/bin/sh/options.c,v 1.37 2011/06/13 21:03:27 jilles Exp $ + * $FreeBSD: src/bin/sh/options.c,v 1.38 2011/11/20 21:48:50 jilles Exp $ */ #include @@ -402,9 +402,10 @@ setcmd(int argc, char **argv) void getoptsreset(const char *value) { - if (number(value) == 1) { + while (*value == '0') + value++; + if (strcmp(value, "1") == 0) shellparam.reset = 1; - } } /* diff --git a/tools/regression/bin/sh/parameters/optind1.0 b/tools/regression/bin/sh/parameters/optind1.0 new file mode 100644 index 0000000000..dfcae047e9 --- /dev/null +++ b/tools/regression/bin/sh/parameters/optind1.0 @@ -0,0 +1,3 @@ +# $FreeBSD: src/tools/regression/bin/sh/parameters/optind1.0,v 1.1 2011/11/20 21:48:50 jilles Exp $ + +unset OPTIND && [ -z "$OPTIND" ]