Skip to content
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

[SR-7831] ArgumentParser parses short option and option-argument without delimiting space as a single (likely unrecognised) option #4800

Open
aciidb0mb3r opened this issue May 31, 2018 · 4 comments
Labels
bug good first issue

Comments

@aciidb0mb3r
Copy link
Member

@aciidb0mb3r aciidb0mb3r commented May 31, 2018

Previous ID SR-7831
Radar rdar://problem/36340481
Original Reporter @aciidb0mb3r
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Package Manager
Labels Bug, StarterBug
Assignee None
Priority Medium

md5: 96d5acc7cd3ec4326fc64597be212962

Issue Description:

`ArgumentParser` parses short option and option-argument without delimiting space as a single (likely unrecognised) option.

For example, if an option is added to the parser with a short name of `-n`, `ArgumentParser` parses `-n 2` as the “n” option with “2” as its option-argument.

But it parses `-n2` as the unknown option `n2`.

Where long options are prefixed with `--`, it is common for CLI to treat `-n2` and `-n 2` identically.

This probably also implies `ArgumentParser` doesn’t handle adjoining flags (e.g. parsing `-abc` identically to `-a -b -c`) — but I haven’t tested this.

@swift-ci
Copy link
Contributor

@swift-ci swift-ci commented Jun 13, 2018

Comment by Shai Mishali (JIRA)

Not sure this is necessarily a correct fix, since `swift -help` and `swift --help` both work.
Meaning, SwiftPM long runtime argument aren't limited to using `--`. (in our case it would be equal to -h -e -l -p, which you probably don't want)

Would love to know what you think @aciidb0mb3r

@aciidb0mb3r
Copy link
Member Author

@aciidb0mb3r aciidb0mb3r commented Jun 13, 2018

I think we can make it work for the options that have a short option declared so it misinterpret options that have a single dash.

@swift-ci
Copy link
Contributor

@swift-ci swift-ci commented Jun 14, 2018

Comment by Shai Mishali (JIRA)

I think accepting `-n2` is easily achievable but accepting `-abc` is much harder, since `-abc` could also be a long option (e.g. if you do `-heyx`, is it `-h -e -y -x`? it is `-hey -x` ? That's sort of what I'm wondering.

Interested in trying to tackle but not sure what's the intended behavior here

@belkadan
Copy link

@belkadan belkadan commented Jul 27, 2019

Resetting assignee for all Starter Bugs not touched since 2018.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 4, 2022
@tomerd tomerd added good first issue and removed Package Manager labels May 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug good first issue
Projects
None yet
Development

No branches or pull requests

4 participants