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
An errant space is inserted in command line when parameter starting with dash and it has a dot. -DFOO=foo.c #14364
When you are calling a program from the command line, if the command line has a parameter that starts with a dash, and it contains a dot, powershell (pwsh and windows powershell) inserts a space and breaks up the parameter into two parameters
this can be demonstrated with cmd with echo
cmd /c echo -DFOO=path/to/foo.c
Expected behavior
-DFOO=path/to/foo.c
Actual behavior
-DFOO=path/to/foo .c
Environment data
Name Value
---- -----
PSVersion 7.1.0
PSEdition Core
GitCommitId 7.1.0
OS Microsoft Windows 10.0.21276
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
I just realized that `-escaping the leading - is another workaround that also helps with some of the other linked issues:
cmd /c echo `-DFOO=path/to/foo.c
(Re quoting: '...' or "..."-quoting any part of the argument helps too, such as -DFOO='path/to/foo.c', but it's important to note in general that selective quoting is not passed through as such to the target executable - on-demand re-quoting is performed).
Activity
jborean93 commentedon Dec 9, 2020
A workaround is to use
--% -DFOO=path/to/foo.cor just quote the argument.mklement0 commentedon Dec 9, 2020
An unfortunate bug, but it has been known for a while: #6291
There are related bugs as well: https://github.com/PowerShell/PowerShell/issues?q=is%3Aissue+is%3Aopen+parameter+parsing+in%3Atitle
mklement0 commentedon Dec 9, 2020
I just realized that
`-escaping the leading-is another workaround that also helps with some of the other linked issues:(Re quoting:
'...'or"..."-quoting any part of the argument helps too, such as-DFOO='path/to/foo.c', but it's important to note in general that selective quoting is not passed through as such to the target executable - on-demand re-quoting is performed).