3
0

getopt_optarg.tests 499 B

123456789101112131415161718
  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'"
  7. OPTARG=ASDFGH
  8. done
  9. echo "exited: var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'"
  10. set -- -w 1 -w2 -w -e -e -t -t
  11. echo "*** OPTIND=0, optstring:'w:et' args:$*"
  12. OPTIND=0
  13. while getopts "w:et" var; do
  14. echo "var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'"
  15. OPTARG=ASDFGH
  16. done
  17. echo "exited: var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'"