Author: jilles
Date: Wed May  7 21:45:25 2014
New Revision: 265616
URL: http://svnweb.freebsd.org/changeset/base/265616

Log:
  sh: Add some tests for normal use of getopts.

Added:
  head/bin/sh/tests/builtins/getopts3.0   (contents, props changed)
  head/bin/sh/tests/builtins/getopts4.0   (contents, props changed)
  head/bin/sh/tests/builtins/getopts5.0   (contents, props changed)
Modified:
  head/bin/sh/tests/builtins/Makefile

Modified: head/bin/sh/tests/builtins/Makefile
==============================================================================
--- head/bin/sh/tests/builtins/Makefile Wed May  7 21:39:01 2014        
(r265615)
+++ head/bin/sh/tests/builtins/Makefile Wed May  7 21:45:25 2014        
(r265616)
@@ -80,6 +80,9 @@ FILES+=               for2.0
 FILES+=                for3.0
 FILES+=                getopts1.0 getopts1.0.stdout
 FILES+=                getopts2.0 getopts2.0.stdout
+FILES+=                getopts3.0
+FILES+=                getopts4.0
+FILES+=                getopts5.0
 FILES+=                hash1.0 hash1.0.stdout
 FILES+=                hash2.0 hash2.0.stdout
 FILES+=                hash3.0 hash3.0.stdout

Added: head/bin/sh/tests/builtins/getopts3.0
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/bin/sh/tests/builtins/getopts3.0       Wed May  7 21:45:25 2014        
(r265616)
@@ -0,0 +1,6 @@
+# $FreeBSD$
+
+shift $#
+getopts x opt
+r=$?
+[ "$r" != 0 ] && [ "$OPTIND" = 1 ]

Added: head/bin/sh/tests/builtins/getopts4.0
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/bin/sh/tests/builtins/getopts4.0       Wed May  7 21:45:25 2014        
(r265616)
@@ -0,0 +1,10 @@
+# $FreeBSD$
+
+set -- -x
+opt=not
+getopts x opt
+r1=$? OPTIND1=$OPTIND opt1=$opt
+getopts x opt
+r2=$? OPTIND2=$OPTIND
+[ "$r1" = 0 ] && [ "$OPTIND1" = 2 ] && [ "$opt1" = x ] && [ "$r2" != 0 ] &&
+       [ "$OPTIND2" = 2 ]

Added: head/bin/sh/tests/builtins/getopts5.0
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/bin/sh/tests/builtins/getopts5.0       Wed May  7 21:45:25 2014        
(r265616)
@@ -0,0 +1,10 @@
+# $FreeBSD$
+
+set -- -x arg
+opt=not
+getopts x opt
+r1=$? OPTIND1=$OPTIND opt1=$opt
+getopts x opt
+r2=$? OPTIND2=$OPTIND
+[ "$r1" = 0 ] && [ "$OPTIND1" = 2 ] && [ "$opt1" = x ] && [ "$r2" != 0 ] &&
+       [ "$OPTIND2" = 2 ]
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to