-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
parseCmdLine doesn't handle quoting correctly (and also prevents passing empty arguments) #14343
Comments
Since there is nothing "intuitive" about the typical shell's behaviour, there is also nothing to change here. IMO. Feel free to use your own |
you made the same argument before see #9951 (comment)
And yet, AFAIK I fixed Likewise in this case.
eg this fails currently: when true: # D20200513T231430:here gitissue
import std/[os,unittest]
let args = @["foo", "baz bam", "--char:'"]
check parseCmdLine(quoteShellCommand(args)) == args # fails: @["foo", "baz bam", "--char:", "\'", ""]
This is of no help for the myriad of API's that consume string instead of The reality is that taking input commands as string instead of [1] one reason I didn't add Once this bug is fixed, [2] as mentioned in top post, I'm not talking about any kind of shell specific command execution/interpretation such as as transforming |
Oh I completely agree with that.
Ok, fair enough, give it a try. |
inadvertantly closed because of PR msg containing |
parseCmdLine doesn't handle quoting correctly. IMO current behavior, even if "works as designed according to docs" is not uesful and should be replaced by a more intuitive behavior.
Example 1
Current Output
fails
Expected Output
works
Example 2
this bug prevents passing empty arguments, eg
--batch:''
or--nimcache:''
(and is the reason why--threads: on
"works" by accident but shouldn't)see
# BUG: with initOptParser, `--batch:'' all` interprets `all` as the argument of --batch`
(refs https://github.com/nim-lang/Nim/pull/14823/files#diff-0bc1750c146a1dfef2e41e4aa555789f310d35a44d7ee97abd35ef3fd128389bR5530)
Example 3
root cause of #18077
Possible Solution
We don't need to reproduce everything the shell does (which is complicated) but at least we should handle quoting correctly. If there is valid use case to keep existing behavior, I suggest we add a new proc, but I doubt there's a valid use case.
Additional Information
The text was updated successfully, but these errors were encountered: