diff options
Diffstat (limited to 'shell/ash_test/ash-getopts')
-rw-r--r-- | shell/ash_test/ash-getopts/getopt_optarg.right | 18 | ||||
-rwxr-xr-x | shell/ash_test/ash-getopts/getopt_optarg.tests | 16 |
2 files changed, 34 insertions, 0 deletions
diff --git a/shell/ash_test/ash-getopts/getopt_optarg.right b/shell/ash_test/ash-getopts/getopt_optarg.right new file mode 100644 index 0000000..dff28de --- /dev/null +++ b/shell/ash_test/ash-getopts/getopt_optarg.right @@ -0,0 +1,18 @@ +*** no OPTIND, optstring:'w:et' args:-q -w e -r -t -y +Illegal option -q +var:'?' OPTIND:2 OPTARG:'' +var:'w' OPTIND:4 OPTARG:'e' +Illegal option -r +var:'?' OPTIND:5 OPTARG:'' +var:'t' OPTIND:6 OPTARG:'' +Illegal option -y +var:'?' OPTIND:7 OPTARG:'' +exited: var:'?' OPTIND:7 OPTARG:'' +*** OPTIND=0, optstring:'w:et' args:-w 1 -w2 -w -e -e -t -t +var:'w' OPTIND:3 OPTARG:'1' +var:'w' OPTIND:4 OPTARG:'2' +var:'w' OPTIND:6 OPTARG:'-e' +var:'e' OPTIND:7 OPTARG:'' +var:'t' OPTIND:8 OPTARG:'' +var:'t' OPTIND:9 OPTARG:'' +exited: var:'?' OPTIND:9 OPTARG:'' diff --git a/shell/ash_test/ash-getopts/getopt_optarg.tests b/shell/ash_test/ash-getopts/getopt_optarg.tests new file mode 100755 index 0000000..b346284 --- /dev/null +++ b/shell/ash_test/ash-getopts/getopt_optarg.tests @@ -0,0 +1,16 @@ +set -- -q -w e -r -t -y +echo "*** no OPTIND, optstring:'w:et' args:$*" +var=QWERTY +OPTARG=ASDFGH +while getopts "w:et" var; do + echo "var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'" +done +echo "exited: var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'" + +set -- -w 1 -w2 -w -e -e -t -t +echo "*** OPTIND=0, optstring:'w:et' args:$*" +OPTIND=0 +while getopts "w:et" var; do + echo "var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'" +done +echo "exited: var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'" |