I'm trying to write a moderately difficult bash program, but somehow I cannot parse command line parameters and set default parameters with getopt.
Getopt is somehow ignoring optional parameters, setting them after the --, which denotes end of parameters.
Simple test, where l(list) is required:
getopt -s bash -o l: -l list: -- -l test
Produces:
-l 'test' --
If I were to define l(list) as optional, then output is:
getopt -s bash -o l:: -l list:: -- -l test
-l '' -- 'test'
I used this example as a base, but as of my testing, even this script does not work as intended(setting arga value to something produces always default value).
OS: Linux, getopt -V=getopt from util-linux 2.27
Any help appreciated :)