OILS / spec / testdata / getopts-1523.sh View on Github | oilshell.org

9 lines, 9 significant
1while getopts abc: opt; do
2 case "$opt" in
3 [ab]) printf 'opt:%s\n' "$opt";;
4 c) printf 'opt:%s arg:%s\n' "$opt" "$OPTARG";;
5 *) printf 'err:%s\n' "$opt";;
6 esac
7done
8shift $((OPTIND - 1))
9[ $# -gt 0 ] && printf 'arg:%s\n' "$@"