Parse positional parameters as options.

Synopsis

getopts OPTSTRING NAME [ARGS]

Description

Parse command options. OPTSTRING contains the option characters to recognize. If a character is followed by a colon, the option is expected to have an argument stored in OPTARG. Runs in the just-bash WASM shell inside SLICC.

Examples

$ while getopts "a:b" opt; do case $opt in a) echo "a=$OPTARG";; b) echo "b";; esac; done

Parse -a (with argument) and -b options.

Variables

OPTARG The value of the current option argument.

OPTIND The index of the next argument to be processed.

See Also

shift, set, case