Skip to content

disappearing getopt argument with only long options #3067

Closed Answered by karelzak
dotysan asked this question in Q&A
Discussion options

You must be logged in to vote

If you do not define --options,-o, then the first parameter is used instead of the --options.

 getopt --long special: -- foo bar --special baz

is the same as

getopt --options foo --long special: -- bar --special baz

See man page:

getopt [options] [--] optstring parameters
getopt [options] -o|--options optstring [options] [--] parameters

So, for your use case, the solution is

getopt -o '' --long special: -- foo bar --special baz

It seems strange, but it was probably originally designed mostly for short options.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@dotysan
Comment options

Answer selected by dotysan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants