Author: jilles
Date: Tue Dec 24 22:38:24 2013
New Revision: 259846
URL: http://svnweb.freebsd.org/changeset/base/259846

Log:
  sh: Initialize OPTIND=1 even if it came from the environment.

Added:
  head/bin/sh/tests/parameters/optind2.0   (contents, props changed)
Modified:
  head/bin/sh/tests/parameters/Makefile
  head/bin/sh/var.c

Modified: head/bin/sh/tests/parameters/Makefile
==============================================================================
--- head/bin/sh/tests/parameters/Makefile       Tue Dec 24 22:24:17 2013        
(r259845)
+++ head/bin/sh/tests/parameters/Makefile       Tue Dec 24 22:38:24 2013        
(r259846)
@@ -10,6 +10,7 @@ FILES+=               exitstatus1.0
 FILES+=                mail1.0
 FILES+=                mail2.0
 FILES+=                optind1.0
+FILES+=                optind2.0
 FILES+=                positional1.0
 FILES+=                positional2.0
 FILES+=                pwd1.0

Added: head/bin/sh/tests/parameters/optind2.0
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/bin/sh/tests/parameters/optind2.0      Tue Dec 24 22:38:24 2013        
(r259846)
@@ -0,0 +1,3 @@
+# $FreeBSD$
+
+[ "$(OPTIND=42 ${SH} -c 'printf %s "$OPTIND"')" = 1 ]

Modified: head/bin/sh/var.c
==============================================================================
--- head/bin/sh/var.c   Tue Dec 24 22:24:17 2013        (r259845)
+++ head/bin/sh/var.c   Tue Dec 24 22:38:24 2013        (r259846)
@@ -188,6 +188,7 @@ initvar(void)
                        setvareq(*envp, VEXPORT|VTEXTFIXED);
                }
        }
+       setvareq("OPTIND=1", VTEXTFIXED);
 }
 
 /*
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to