You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Experimental feature PSNativeCommandArgumentPassing doesn't support arguments with embedded double quotes when calling batch files #15250
Similar to #15239, this issue would be resolved by the proposal in #15143. See also: #15261 and #15276
Note that high-profile CLIs such as az and npm (Node.js's package manager), for script-based utilities that come with packages, use batch files as their entry points.
Steps to reproduce
Run the following on Windows:
# Switch to a temporary directory.Push-Location-ea Stop ($tmpDir= (New-Item-Type Directory -Force (Join-Path Temp:/$PID)).FullName)
# Create a batch file that strips enclosing double quotes from the first argument and deduplicates the # embedded ones.@'@echo off & setlocalset Arg1=%~1echo [%Arg1:""="%] [%2]'@>foo.cmd
./foo.cmd'Andre "The Hawk" Dawson'| Should -Be '[Andre "The Hawk" Dawson] []'# Clean up.Pop-Location; Remove-Item$tmpDir-Recurse
Expected behavior
The test should succeed.
Actual behavior
The test fails, because the argument with embedded " isn't passed batch-file-appropriately - batch files (cmd.exe) do not recognize \" as an escaped " and require "" instead:
InvalidResult: Expected strings to be the same, but they were different.
Expected length: 28 Actual length: 30 Strings differ at index 7.
Expected: '[Andre "The Hawk" Dawson] []'
But was: '[Andre \"The] [Hawk\" Dawson"]'
Note the literally retained \ and the unexpected breakup into two arguments.
For this invocation to succeed it would have to pass verbatim Andre "The Hawk" Dawson as "Andre ""The Hawk"" Dawson" - i.e. escaping the embedded " as "" rather than \" - on the command line used behind the scenes.
changed the title [-]Experimental feature PSNativeCommandArgumentPassing doesn't support with embedded double quotes when calling batch files[/-][+]Experimental feature PSNativeCommandArgumentPassing doesn't support arguments with embedded double quotes when calling batch files[/+]on Apr 16, 2021
It is part of what I've been proposing for months, repeatedly, in conversations you were a part of: here and here and here, which finally evolved into a - hopefully comprehensive and final - proposal in #15143, which summarizes all accommodations that I think are vital to make on Windows, the need to escape " as "" for batch files being just one of them.
Excuse me for shouting, but it's out of desperation over these issues seemingly never being paid proper attention to; this isn't a personal concern; rather, I think these issues are of vital importance for all PowerShell users, and we should finally get them right.
Therefore, I ask you to please take the time to fully understand and discuss:
This issue has not had any activity in 6 months, if there is no further activity in 7 days, the issue will be closed automatically.
Activity in this case refers only to comments on the issue. If the issue is closed and you are the author, you can re-open the issue using the button below. Please add more information to be considered during retriage. If you are not the author but the issue is impacting you after it has been closed, please submit a new issue with updated details and a link to this issue and the original.
Activity
[-]Experimental feature PSNativeCommandArgumentPassing doesn't support with embedded double quotes when calling batch files[/-][+]Experimental feature PSNativeCommandArgumentPassing doesn't support arguments with embedded double quotes when calling batch files[/+]SteveL-MSFT commentedon Apr 18, 2021
The proposed fix would be to special case
cmd.exeand files ending with.bator.cmdto pass enclosed double quotes as""?mklement0 commentedon Apr 18, 2021
Indeed, Steve Lee (@SteveL-MSFT).
It is part of what I've been proposing for months, repeatedly, in conversations you were a part of: here and here and here, which finally evolved into a - hopefully comprehensive and final - proposal in #15143, which summarizes all accommodations that I think are vital to make on Windows, the need to escape
"as""for batch files being just one of them.Excuse me for shouting, but it's out of desperation over these issues seemingly never being paid proper attention to; this isn't a personal concern; rather, I think these issues are of vital importance for all PowerShell users, and we should finally get them right.
Therefore, I ask you to please take the time to fully understand and discuss:
Moved to #15143 (comment)
mklement0 commentedon Apr 19, 2021
Steve Lee (@SteveL-MSFT), I've moved the gist of my previous comment to #15143 (comment), to have all the relevant information in one place.
Note that a new bug has since joined the ranks: #15276
seanbudd commentedon Jun 26, 2023
Any updates on this bug?
Add quotes around submission input to prevent parsing issues (#1008)
Convert batch scripts to powershell, write validation error if zip in…
seanbudd commentedon Dec 24, 2023
Bump to keep open
seanbudd commentedon Jun 22, 2024
Bump to keep open
microsoft-github-policy-service commentedon Dec 19, 2024
This issue has not had any activity in 6 months, if there is no further activity in 7 days, the issue will be closed automatically.
Activity in this case refers only to comments on the issue. If the issue is closed and you are the author, you can re-open the issue using the button below. Please add more information to be considered during retriage. If you are not the author but the issue is impacting you after it has been closed, please submit a new issue with updated details and a link to this issue and the original.
brian6932 commentedon Dec 26, 2024
This is still an issue, any maintainers around to reopen?
Convert batch scripts to powershell, write validation error if zip in…