Denys Vlasenko | 007ce9f | 2017-08-13 02:59:00 +0200 | [diff] [blame] | 1 | ( |
| 2 | |
Denys Vlasenko | 81f962f | 2017-08-11 02:05:21 +0200 | [diff] [blame] | 3 | set -- -q -w e -r -t -y |
| 4 | echo "*** no OPTIND, optstring:'w:et' args:$*" |
| 5 | var=QWERTY |
| 6 | OPTARG=ASDFGH |
| 7 | while getopts "w:et" var; do |
| 8 | echo "var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'" |
Denys Vlasenko | 9a7d0a0 | 2017-08-11 02:37:48 +0200 | [diff] [blame] | 9 | OPTARG=ASDFGH |
Denys Vlasenko | 81f962f | 2017-08-11 02:05:21 +0200 | [diff] [blame] | 10 | done |
| 11 | echo "exited: var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'" |
| 12 | |
| 13 | set -- -w 1 -w2 -w -e -e -t -t |
| 14 | echo "*** OPTIND=0, optstring:'w:et' args:$*" |
| 15 | OPTIND=0 |
| 16 | while getopts "w:et" var; do |
| 17 | echo "var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'" |
Denys Vlasenko | 9a7d0a0 | 2017-08-11 02:37:48 +0200 | [diff] [blame] | 18 | OPTARG=ASDFGH |
Denys Vlasenko | 81f962f | 2017-08-11 02:05:21 +0200 | [diff] [blame] | 19 | done |
| 20 | echo "exited: var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'" |
Denys Vlasenko | 007ce9f | 2017-08-13 02:59:00 +0200 | [diff] [blame] | 21 | |
| 22 | ) 2>&1 \ |
| 23 | | sed -e 's/ unrecognized option: / invalid option -- /' \ |
| 24 | -e 's/ illegal option -- / invalid option -- /' \ |