-
Notifications
You must be signed in to change notification settings - Fork 991
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
scriptName
breaks completion script if it contains whitespace
#2387
Comments
I agree it is a short-coming, but under what circumstances would it come up in practice? A script with a space in the name seems unlikely. However, if you actually encountered this bug in real world then definitely of interest! |
The "run script" example is thought provoking! But wouldn't your PR install a completion definition for a command named |
The existing tests are in |
No, there are 2 template strings in the completion bash function where the |
These are two different and incompatible use cases. (I was having another look at this and realised conflating two different use cases.) In the first case there is a command with a space in it. It gets invoked like:
In the second case there is a command with an argument:
|
In the implementation I didn't give any thought to the "command with a space" in it case. I don't think there are many developers that would think about designing a command name that has to be quoted to use it. It also doesn't work with yargs completion currently, so improving yargs completion to allow for the common "multiple argument command" case shouldn't affect it, right? |
Reproduction:
One liner:
You can paste this into your terminal to get a quick reproduction:
mkdir scriptNameCompletionTest && cd scriptNameCompletionTest && npm install yargs --no-save >/dev/null && node -e 'require("yargs").scriptName("yarn whatever").completion().parseSync(["completion"])'
The output:
Notice the invalid bash function
_yarn whatever_yargs_completions
.I think if
scriptName
is going to be used in the generated bash completion script it should be sanitized (https://stackoverflow.com/a/28115066/160173). Or completions should allow the use to specify their own function name.The text was updated successfully, but these errors were encountered: