Skip to content
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

& operator launches commands differently in 7.3.0 #18568

Closed
5 tasks done
wasker opened this issue Nov 15, 2022 · 7 comments
Closed
5 tasks done

& operator launches commands differently in 7.3.0 #18568

wasker opened this issue Nov 15, 2022 · 7 comments
Labels
Resolution-Answered The question is answered.

Comments

@wasker
Copy link

wasker commented Nov 15, 2022

Prerequisites

Steps to reproduce

Program.cs.txt
test.ps1.txt

  1. Build C# app called blah.exe using Program.cs, make sure it's on the path.
  2. Run pwsh -f test.ps1 and observe the output.

Expected behavior

On 7.2.7:

Something will happen: working...
Something will happen: done.
--set
deployment.environment=blah
--set
deployment.region=blah
--set
deployment.image.repository=blah

Actual behavior

On 7.3.0:

Something will happen: working...
Something will happen: done.
--set
deployment.environment="blah"
--set
deployment.region="blah"
--set
deployment.image.repository="blah"

Error details

No response

Environment data

Name                           Value
----                           -----
PSVersion                      7.3.0
PSEdition                      Core
GitCommitId                    7.3.0
OS                             Microsoft Windows 10.0.19044
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

No response

@wasker wasker added the Needs-Triage The issue is new and needs to be triaged by a work group. label Nov 15, 2022
@mklement0
Copy link
Contributor

mklement0 commented Nov 15, 2022

This is ultimately a duplicate of #18554, but let me add some context:

  • v7.3.0 introduced a breaking change with respect to how arguments with embedded " characters as well as empty-string arguments are passed to external programs: a longstanding bug was fixed, fully on Unix, partially on Windows.

  • Existing workarounds that build on the old, broken behavior now break - except in calls to batch files and WSH scripts, where the legacy workarounds will continue to work by default.

  • The fixed behavior now correctly escapes embedded " characters as \" on the process command line PowerShell constructs behind the scenes, which is the most widely observed convention on Windows, and also supports passing empty strings as arguments.

    • Thus, an argument such as "deployment.environment=`"blah`"", which from PowerShell's perspective has a verbatim value of deployment.environment="blah" is now placed as follows on the target process' command line: "deployment.environment=\"blah\"", and if the target process observes the aforementioned convention, it ends up parsing that again as verbatim deployment.environment="blah", which is what you saw.

There's additional background information in this Stack Overflow answer.

@wasker
Copy link
Author

wasker commented Nov 15, 2022

Thank you for the links!

There's no mention of this behavior change in relnotes for 7.3.0 - https://github.com/PowerShell/PowerShell/releases/tag/v7.3.0

GitHub
7.3.0 - 2022-11-08 General Cmdlet Updates and Fixes

Correct calling cmdlet New-PSSessionOption in script for Restart-Computer (#18374)

Tests

Add test for framework dependent package in release p...

@mklement0
Copy link
Contributor

mklement0 commented Nov 15, 2022

My pleasure, @wasker.

There's no mention of this behavior change in relnotes for 7.3.0 -https://github.com/PowerShell/PowerShell/releases/tag/v7.3.0

That GitHub link doesn't provide a cumulative view of what changed in that release - it just shows whatever changed in the final commit that led to the release.

GitHub
7.3.0 - 2022-11-08 General Cmdlet Updates and Fixes

Correct calling cmdlet New-PSSessionOption in script for Restart-Computer (#18374)

Tests

Add test for framework dependent package in release p...

GitHub
PowerShell for every system! Contribute to PowerShell/PowerShell development by creating an account on GitHub.
A collection of release notes and documentation about the new features available in new versions of PowerShell.
New features and changes released in PowerShell 7.3
PowerShell Team
General availability of PowerShell 7.3

@SteveL-MSFT
Copy link
Member

cc @michaeltlombardi

The content team should have plans to have an about topic specifically around using native commands in PS7 and I expect will capture these types of details

@daxian-dbw daxian-dbw added Resolution-Answered The question is answered. and removed Needs-Triage The issue is new and needs to be triaged by a work group. labels Nov 16, 2022
@jhoneill
Copy link

@SteveL-MSFT - given that this is the second report of this issue in as many days, I wonder if it might be wiser for the default value of $PSNativeCommandArgumentPassing to be legacy. ? I think (as @mklement0 says) the previous behaviour was a bug, but one which so many had lived with for so long it became "standard" - I put this as an open question because what gives the best gain:pain ratio is not obvious to me :-)

Some of the 7.3 changes (PSReadline prediction being on, colouring directories, formatting of floating point in tables, the change to convertFrom-Json -as hash table, and this one) need to publicized more than they have been , the community can help on that but docs and team blog probably need to to take the lead. I'm for 3/5 of those, against 1/5, and this one I'm not sure about. Not all changes are bad, but surprises generally are, especially if the explanation is hard to find.

@ghost
Copy link

ghost commented Nov 17, 2022

This issue has been marked as answered and has not had any activity for 1 day. It has been closed for housekeeping purposes.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution-Answered The question is answered.
Projects
None yet
Development

No branches or pull requests

5 participants