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
fix: wrap unknown args in quotes #2092
Conversation
@jly36963 If I'm understanding correclty, the problem is the form:
And this would work?
I like your approach of making this jump out better to people. |
This causes the shell to throw
This causes yargs to throw
(I think the second scenario would only happen if there is some process (before execution) adding backslashes at the end of lines that don't have them.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I say ship it 👌this will at least help people identify this odd edge case.
@bcoe It wouldn't take very long |
@jly36963 sounds like consistentcy would be worthwhile, did you want to do so in this PR, or merge this PR and have some follow up work? |
@bcoe |
@bcoe |
Addresses:
#2033
Problem
If an unknown argument is only whitespace, it causes confusing output:
Unknown argument:
Reproduction
Code
Explanation
Calling multiline.js from multiline.sh (version 1) will result in an error like
command not found
. This makes sense, as having a space between the backslash and newline will prevent the newline from being escaped, and the newline would cause the next line to be interpreted as a new command.Calling multiline.js from multiline.sh (version 2) will result in the
unknown argument:
error. I added a.map()
call to the unknown arguments that will wrap them in quotes. This will make the error described in the issue a bit easier to understand:Unknown argument: " "
I don't know what might cause the situation in version 2. The issue specifically mentioned the error happening in a multiline
run: |
command in github actions. Maybe there's some process (like something in the github actions runner) that adds backslashes (where missing) at the end of each line within a multiline command. If something like this is happening, then extra backslashes would be added to the end of lines with trailing whitespace. I only have suspicions, and I feel like investigating it is outside the scope of this fix.Solution
The solution mentioned in the comments section of the issue was to wrap arguments listed in the usage output in quotes, rather than trimming/mutating the elements of argv.
Questions
For the usage output:
missing required argument: %s
, etc)