3
0

getopt_optarg.tests 622 B

123456789101112131415161718192021222324
  1. (
  2. set -- -q -w e -r -t -y
  3. echo "*** no OPTIND, optstring:'w:et' args:$*"
  4. var=QWERTY
  5. OPTARG=ASDFGH
  6. while getopts "w:et" var; do
  7. echo "var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'"
  8. OPTARG=ASDFGH
  9. done
  10. echo "exited: var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'"
  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'"
  16. OPTARG=ASDFGH
  17. done
  18. echo "exited: var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'"
  19. ) 2>&1 \
  20. | sed -e 's/ unrecognized option: / invalid option -- /' \
  21. -e 's/ illegal option -- / invalid option -- /' \