Powershell: stop-parsing symbol works unexpectedly

Created on 31 Jul 2019  路  2Comments  路  Source: PowerShell/PowerShell


Powershell stop-parsing symbol (--%), works unexpectedly with escaped single quotes.

Steps to reproduce

echo "HI" > 'test file.txt'
&"cmd.exe" "--%" "/c type `'test file.txt`'"

Expected behavior

Must print 'HI'

Actual behavior

Prints error:
The system cannot find the file specified.
Error occurred while processing: 'test.
The system cannot find the file specified.
Error occurred while processing: file.txt'.

But with it works if i escape double quoutes

echo "HI" > 'test file.txt'
&"cmd.exe" "--%" "/c type `"test file.txt`""

Environment data

Name                           Value
----                           -----
PSVersion                      6.2.2
PSEdition                      Core
GitCommitId                    6.2.2
OS                             Microsoft Windows 10.0.17134
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0鈥
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
Issue-Question Resolution-Answered

All 2 comments

I didn't think cmd respected single quotes in the same way PowerShell does?

Yeah, shame on me. Spent all day struggling with a ghost >_<.
Sorry to bother.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

andschwa picture andschwa  路  64Comments

SteveL-MSFT picture SteveL-MSFT  路  189Comments

msftrncs picture msftrncs  路  62Comments

mklement0 picture mklement0  路  74Comments

joeyaiello picture joeyaiello  路  66Comments