The Fidelix Linux Distribution

Simple, Stable, and Secure

GETOPT(1) User Commands GETOPT(1)

getopt - manual page for getopt 1.31.1

getopt [OPTIONS] [--] OPTSTRING PARAMS

BusyBox v1.31.1 (2020-04-30 13:38:01 EDT) multi-call binary.
-a
Allow long options starting with single -
-l LOPT[,...]
Long options to recognize
-n PROGNAME
The name under which errors are reported
-o OPTSTRING
Short options to recognize
-q
No error messages on unrecognized options
-Q
No normal output
-s SHELL
Set shell quoting conventions
-T
Version test (exits with 4)
-u
Don't quote output

Example:

O=`getopt -l bb: -- ab:c:: "$@"` || exit 1 eval set -- "$O" while true; do

case "$1" in -a) echo A; shift;; -b|--bb) echo "B:'$2'"; shift 2;; -c) case "$2" in
"")
echo C; shift 2;;
*)
echo "C:'$2'"; shift 2;;
esac;;
--)
shift; break;;
*)
echo Error; exit 1;;
esac

done

April 2020 Fidelix 1.0