sh: Allow unsetting OPTIND.
authorPeter Avalos <pavalos@dragonflybsd.org>
Sun, 25 Dec 2011 17:16:48 +0000 (09:16 -0800)
committerPeter Avalos <pavalos@dragonflybsd.org>
Sun, 25 Dec 2011 17:25:41 +0000 (09:25 -0800)
Obtained-from:  FreeBSD 227773

bin/sh/options.c
tools/regression/bin/sh/parameters/optind1.0 [new file with mode: 0644]

index 69dbfc5..b3cb352 100644 (file)
@@ -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 <signal.h>
@@ -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 (file)
index 0000000..dfcae04
--- /dev/null
@@ -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" ]