Allows you to combine getopt with getopts and also get rid of the need for --longopt=x
OPTOUT=1
- Only display all received arguments, do not parse
SHORTDASH=1
- Print one dash before short parsed arguments
PARSER=1
- Separate the key and its value from each other with a straight line (|
)
./sortopts "a:b:c:d:-" "one:,two,three::" \
-a1 -b 2 -c3 -d 4 \
--one --two --three 3
bash
getopt
(from util-linux
)
Use legacyopts
. There, for parsing short arguments, getopts
is used - a utility built into the bash.
Keep in mind that handling x::
and x:-
arguments will NOT work in this version of the script.