sh: Add some tests for normal use of getopts.
This commit is contained in:
parent
97a9b0b123
commit
5699ef2588
@ -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
|
||||
|
6
bin/sh/tests/builtins/getopts3.0
Normal file
6
bin/sh/tests/builtins/getopts3.0
Normal file
@ -0,0 +1,6 @@
|
||||
# $FreeBSD$
|
||||
|
||||
shift $#
|
||||
getopts x opt
|
||||
r=$?
|
||||
[ "$r" != 0 ] && [ "$OPTIND" = 1 ]
|
10
bin/sh/tests/builtins/getopts4.0
Normal file
10
bin/sh/tests/builtins/getopts4.0
Normal file
@ -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 ]
|
10
bin/sh/tests/builtins/getopts5.0
Normal file
10
bin/sh/tests/builtins/getopts5.0
Normal file
@ -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 ]
|
Loading…
Reference in New Issue
Block a user