Denys Vlasenko | 81f962f | 2017-08-11 02:05:21 +0200 | [diff] [blame] | 1 | set -- -q -w e -r -t -y |
| 2 | echo "*** no OPTIND, optstring:'w:et' args:$*" |
| 3 | var=QWERTY |
| 4 | OPTARG=ASDFGH |
| 5 | while getopts "w:et" var; do |
| 6 | echo "var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'" |
Denys Vlasenko | 9a7d0a0 | 2017-08-11 02:37:48 +0200 | [diff] [blame] | 7 | OPTARG=ASDFGH |
Denys Vlasenko | 81f962f | 2017-08-11 02:05:21 +0200 | [diff] [blame] | 8 | done |
| 9 | echo "exited: var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'" |
| 10 | |
| 11 | set -- -w 1 -w2 -w -e -e -t -t |
| 12 | echo "*** OPTIND=0, optstring:'w:et' args:$*" |
| 13 | OPTIND=0 |
| 14 | while getopts "w:et" var; do |
| 15 | echo "var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'" |
Denys Vlasenko | 9a7d0a0 | 2017-08-11 02:37:48 +0200 | [diff] [blame] | 16 | OPTARG=ASDFGH |
Denys Vlasenko | 81f962f | 2017-08-11 02:05:21 +0200 | [diff] [blame] | 17 | done |
| 18 | echo "exited: var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'" |