aboutsummaryrefslogtreecommitdiff
path: root/shell/hush_test
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2017-08-11 17:21:14 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2017-08-11 17:21:14 +0200
commit419db0391e47444dd12fb052613fd415694d04f0 (patch)
tree0b989526666cd6150b7bae6151f9273c4a5db487 /shell/hush_test
parent129e1ce72c28ec14aee459cceffc25ed9d5cae85 (diff)
downloadbusybox-w32-419db0391e47444dd12fb052613fd415694d04f0.tar.gz
busybox-w32-419db0391e47444dd12fb052613fd415694d04f0.tar.bz2
busybox-w32-419db0391e47444dd12fb052613fd415694d04f0.zip
hush: implement "silent" optstrings of ":opts"
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/hush_test')
-rw-r--r--shell/hush_test/hush-getopts/getopt_silent.right6
-rwxr-xr-xshell/hush_test/hush-getopts/getopt_silent.tests23
2 files changed, 29 insertions, 0 deletions
diff --git a/shell/hush_test/hush-getopts/getopt_silent.right b/shell/hush_test/hush-getopts/getopt_silent.right
new file mode 100644
index 000000000..03d4eb149
--- /dev/null
+++ b/shell/hush_test/hush-getopts/getopt_silent.right
@@ -0,0 +1,6 @@
1*** optstring:':ac' args:-a -b -c
21 rc:0 var:'a' OPTIND:2 OPTARG:''
32 rc:0 var:'?' OPTIND:3 OPTARG:'b'
43 rc:0 var:'c' OPTIND:4 OPTARG:''
54 rc:1 var:'?' OPTIND:4 OPTARG:''
65 rc:1 var:'?' OPTIND:4 OPTARG:''
diff --git a/shell/hush_test/hush-getopts/getopt_silent.tests b/shell/hush_test/hush-getopts/getopt_silent.tests
new file mode 100755
index 000000000..097d7ba85
--- /dev/null
+++ b/shell/hush_test/hush-getopts/getopt_silent.tests
@@ -0,0 +1,23 @@
1# Open Group Base Specifications Issue 7:
2# """
3# If an unknown option is met, VAR shall be set to "?". In this case,
4# if the first character in optstring is ":", OPTARG shall be set
5# to the option character found, but no output shall be written
6# to standard error; otherwise, the shell variable OPTARG shall be
7# unset and a diagnostic message shall be written to standard error."
8# ...
9# If an option-argument is missing:
10# If the first character of optstring is ":", VAR shall be set to ":"
11# and OPTARG shall be set to the option character found.
12# """
13
14echo "*** optstring:':ac' args:-a -b -c"
15getopts ":ac" var -a -b -c; echo "1 rc:$? var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'"
16getopts ":ac" var -a -b -c; echo "2 rc:$? var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'"
17getopts ":ac" var -a -b -c; echo "3 rc:$? var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'"
18getopts ":ac" var -a -b -c; echo "4 rc:$? var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'"
19# Previous line should result in "rc:1", which is normally treated
20# in getopts loops as exit condition.
21# Nevertheless, let's verify that calling it yet another time doesn't do
22# anything weird:
23getopts ":ac" var -a -b -c; echo "5 rc:$? var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'"