Denys Vlasenko | 238ff98 | 2017-08-29 13:38:30 +0200 | [diff] [blame] | 1 | # Test that there is no interference of getopt() |
| 2 | # in getopts and unset. |
| 3 | # It's unclear what "correct" OPTIND values should be |
| 4 | # for "b" and "c" results from "-bc": 2? 3? |
| 5 | # What we focus on here is that all options are reported |
| 6 | # correct number of times and in correct sequence. |
| 7 | |
| 8 | ( |
| 9 | |
| 10 | loop=99 |
| 11 | while getopts "abc" var -a -bc -abc -def -a; do |
| 12 | echo "var:$var" #OPTIND:$OPTIND |
| 13 | # this may use getopt(): |
| 14 | unset -ff func |
| 15 | test $((--loop)) = 0 && break # BUG if this triggers |
| 16 | done |
| 17 | echo "End: var:$var OPTIND:$OPTIND" |
| 18 | |
| 19 | ) 2>&1 \ |
| 20 | | sed -e 's/ unrecognized option: / invalid option -- /' \ |
| 21 | -e 's/ illegal option -- / invalid option -- /' \ |