-
Notifications
You must be signed in to change notification settings - Fork 63
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
Bug in optflagopt #104
Comments
Hi, It seems to be expected: Lines 412 to 427 in c11eb65
|
After digging a bit deeper the issue seems to be mainly to do with the parsing of an |
@ghostd Yes, I've seen that whilst I was writing a fix and I'm correcting that test which I think it is wrong in my opinion. |
When the optflagopt long version is used the parser is ignoring the argument.
Upon further attentive reading I did spot under the Parsing section of the Linux getopt user command https://man7.org/linux/man-pages/man1/getopt.1.html on the second to last paragraph the rules of engagement regarding the handling of optional arguments. I've close the associated MR for now and I'll close this afterwards if no other insightful comments materialize ... |
This is still true in
therefore I expected(wrongly I see) that Furthermore, in accordance with that above doc, the usage via
as if using a space there, even for the long option, is accepted. But maybe that's kind of relaxed, and assumes docs were read by whoever uses the binary, i dno, because how would that be shown otherwise? That being said, gnu
that's this:
therefore I guess the issue happens only for optional arguments of long options, not for required arguments of long options, which in retrospect makes sense now, because how could it know if Maybe the doc needs a little rewording then, to make sure long opts can't expect their optional arg after a space, only after an equals sign. And long opts that require an arg, can expect it after either a space or an equal sign. It's unclear from this |
with tiny examples see comment: rust-lang#104 (comment)
with tiny examples see comment: rust-lang#104 (comment)
with tiny examples see comment: rust-lang#104 (comment)
I've bumped into some weird behaviour in another project whereas the use of an
optflagopt
option seemed to render unexpected behaviour of the option not being properly parsed.I decided to come to the source and I extended the mod.rs test to show that something was amiss
pecastro@de5e4db
I've managed to make the test panic when you use an
optflagopt
in combination with other options.Initial investigations from debugging the test show that the vals Vec of the Matches struct will have a Vec with
Given
rather than the option value specified and that is what's causing the return of None and triggering the panic.self.vals:
The text was updated successfully, but these errors were encountered: