-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Quoted parameter short flag handling with quotes is wonky #1174
Comments
I'm just using standard C getopt-long stuff. Perhaps most of the stuff you work with are using meatier/extended CLI parsing code? I'm not sure there's anything I could even do to make that work without writing the whole parser myself. I can check. |
I've not heard of anyone else using kubies having this problem btw. is this cli quoting an unusual form of providing the arguments or something? |
I don't think so? I'm just doing like...
If this is all just standard stuff and it's what we get without a larger investment, I'm fine to close, it just really caught me off guard. |
Yeah, looks like this is just a getopt_long side effect for optional string args (so like |
it seems super bizarre to me to quote commandline arguments like that. I'll still take a look before considering this closed though. |
From #1174: "-l localhost:11211" will fail. internally we end up with a suboption string of " localhost:11211" instead of "localhost:11211". The same happens with `-o` suboptions. A simple fix to to ensure we skip leading whitespace in optarg.
with
with
So when you quote it getopt is dealing with a longer substring and actually parses it slightly differently. When I get the suboption in the quoted case, it looks like Just pushed a fix for this to |
Pushed to |
Describe the bug
Maybe I'm crazy and this is how it works for other CLIs and I've just never noticed, but it feels very surprising:
memcached -l localhost:11211
- This worksmemcached --listen=localhost:11211
- This worksmemcached "-l localhost:11211"
- This failsmemcached "-llocalhost:11211"
- This worksThat third one is especially impactful and surprising in kubernetes environments, as you may do:
which will be translated into...
memcached "-l localhost:11211"
and cause an error.This behavior is not exclusive to the
l
flag, but is present on many other short flags (notably,-o
is also effected in an odd way, simply sayingIllegal suboption "(null)"
)To Reproduce
memcached "-l localhost:11211"
System Information
The text was updated successfully, but these errors were encountered: