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 |
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: