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
In pwsh 7.3.0 the call operator escapes embedded quotes. #18756
Comments
$json = ConvertTo-Json @{ item1 = 'abc'; item2 = 'def' }
& bash -c "echo '$json'"
# $PSNativeCommandArgumentPassing = 'Standard' or 'Windows'
{
"item1": "abc",
"item2": "def"
}
# $PSNativeCommandArgumentPassing = 'Legacy'
{
item1: abc,
item2: def
} |
There isn't a description or explanation in your post and I don't see embedded quotes or similar escaping problems in the sample so its rather different than what I posted about. However, the inclusion of the
|
I do not know what I could explain. About experimental variable? Its behavior in different cases is not fully understood. I only showed examples. Similar one: > $PSNativeCommandArgumentPassing = 'Legacy'
> & /usr/bin/echo $json | jq '.'
parse error: Invalid numeric literal at line 2, column 8 # error. Parser does not know where property name and where value
> $PSNativeCommandArgumentPassing = 'Standard'
> & /usr/bin/echo $json | jq '.'
{
"item2": "def",
"item1": "abc"
}
|
Closing as this seems well issued and discussed. Thanks for the help everyone. |
The question. Why quotes are escaped in a argument of json format? Maybe in other formats where quotes are the element of syntax? |
Prerequisites
Steps to reproduce
After upgrading to 7.3.0 from 7.2.7 I noticed that the string passed in via the call operator retrieved from
Environment.CommandLine
has escaped embedded quotes that were not part of the original string. This is only in 7.3.0 as pwsh 7.2.7 and earlier and powershell 5.1 do not do this. I came across the problem with a custom tool (that uses libstandard2.0 and .net 4.8 for the libraries and exe respectively) that takes in json like this:where $json normally contains:
but when I output the contents of
Environment.CommandLine
from the tool with 7.3.0 it looks like this:If I use Start-Process instead of the call operator then the string is left alone:
I came across this issue #18660 which mentions
After the breaking change in native command execution
but I could not find details on that breaking change or its impact in the release notes: https://learn.microsoft.com/en-us/powershell/scripting/whats-new/what-s-new-in-powershell-73?view=powershell-7.3Expected behavior
The string should be unmodified:
Actual behavior
The string is escaped:
Error details
No response
Environment data
Visuals
No response
The text was updated successfully, but these errors were encountered: