getopt optional parameters without the use of the format --name=value

89 Views Asked by At

I have getopt from util-linux 2.38 on my system:

[davide@68YM9C3 tmp]$ getopt -V
getopt from util-linux 2.38
[davide@68YM9C3 tmp]$

I would like to have an optional parameter to a long option but I would like to input its value (when I intend to input it) without the use of the format

--option=value

opting for the format supported for the mandatory parameters

--option value

Example:

[davide@68YM9C3 ~]$ getopt -a -o abc: --long option:: -- -a -b -c a -option value
-a -b -c 'a' --option '' -- 'value'

You see here the value went into the non-option arguments after -- and --option took an empty value. The intended response should have been much like when using = but I would rather not be forced to use it

[davide@68YM9C3 ~]$ getopt -a -o abc: --long option:: -- -a -b -c a -option=value
-a -b -c 'a' --option 'value' --

Does anyone know if it can be done by using getopt? I don't particularly want to write a complicated case to properly distinguish optional parameters and options themselves.

0

There are 0 best solutions below