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
The concatenation of differently quoted command line arguments splits into multiple argv. #15888
Comments
PS supports both single and double quoted string, so I'm not sure this is really unexpected. Your example has three separate string tokens in it, so they get passed as three separate arguments. PS's parsing treats " and ' as enclosing characters for strings, and it doesn't support concatenation like this. Three separate strings, three separate arguments. |
See also #15889. The differently quoted strings are scanned on the first view as three separate string tokens, but they miss a SEPARATOR. The "outer" quotes of a string are commonly dropped from a parsed command line string as these are temporary markers grouping the characters into a string. This would result in three concatenated strings with dropped temporary markers - the quotes. Thus as expected a single concatenated string argument - ARGV entry. The same example for Posix based shells - bash/sh/ksh. for WSL/Linux:
and for native Linux:
|
/cc @mklement0 |
Duplicate of #1995 |
This issue has been marked as duplicate and has not had any activity for 1 day. It has been closed for housekeeping purposes. |
The problem is unrelated to #1995 - it equally affects PowerShell commands. Instead, it is a specific instance of #6467 and - on Unix with potentially destructive consequences - #12647 The short of it is that composing a single string argument from a mix of quoting styles - the way you can do in POSIX-like shells such as # OK - single argument, because the first token is *unquoted*.
PS> Write-Output foo'bar'
foobar
# !! TWO arguments
PS> Write-Output 'bar'foo
bar
foo More info in this SO answer. |
Prerequisites
Steps to reproduce
The concatenation of differently quoted string arguments for a command line call is resolved into separate argv entries.
For example a python one-liner, same for PowerShell scripts etc.
-> Call: C:\temp\PowerShell-7.1.3-win-x64> c:/Python371/python.exe -c "import sys;print(sys.argv[1:])" "a"'b'"c"
-> Result: ['a', 'b', 'c']
I would expect these strings to be actually concatenated into one string:
-> Result: ['abc']
As this is the case e.g. for:
-> Call: C:\temp\PowerShell-7.1.3-win-x64> c:/Python371/python.exe -c "import sys;print(sys.argv[1:])" "a""b""c"
-> Result: ['abc']
Expected behavior
Actual behavior
Error details
No response
Environment data
Visuals
No response
The text was updated successfully, but these errors were encountered: