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

Subcommand parsing: "fooasdf -o=foo" is incorrectly identified as the subcommand "foo" #92

Closed
kmoe opened this issue Apr 21, 2022 · 0 comments · Fixed by #93
Closed

Comments

@kmoe
Copy link
Contributor

kmoe commented Apr 21, 2022

Consider a command with a single subcommand foo.

Running the command with arguments fooasdf -o=bar returns a usage error, return code 127.

However, running the command with arguments fooasdf -o=foo does not return an error, and instead sets the subcommand to foo. This is incorrect - this example should exit 127 just as above.

This problem was seen in hashicorp/terraform#30870, in which terraform planasdf -out tfplan, which should error, instead behaves as if the user had run terraform plan -out tfplan.

The problem seems to be that the subcommand matching logic at https://github.com/mitchellh/cli/blob/master/cli.go#L704 is too liberal, and identifies any string both prefixed and suffixed by a subcommand as that subcommand.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant