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
Stop-parsing symbol on Unix-like platform doesn't support single-quoted arguments #10831
Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-DuplicateThe issue is a duplicate.
The idea behind --% is to pass command lines that use the platform-native shell through, with minimal interpretation by PowerShell.
While --% with its cmd-style environment-variable expansion is an awkward fit for Unix-like platforms to begin with, it does work in principle, but only with double-quoted arguments ("...").
However, the POSIX-like shells (such as Bash) that are native to Unix-like platforms also understand single-quoted strings (...) - verbatim strings.
--% currently doesn't support the latter.
Note that on Unix someone has to break the command line into individual arguments before passing the latter to the target process; unlike on Windows, you cannot start processes with single-string command lines in the native process-creation APIs, so truly passing a command line through isn't an option.
Steps to reproduce
# Note: From Bash itself, running# bash -c 'echo "$1 $RANDOM"' - 'I'\''m'# works correctly and yields something like "I'm 1234"
bash --% -c 'echo "$1 $RANDOM"' - 'I'\''m'$LASTEXITCODE| Should -Be 0
Expected behavior
The test should succeed.
Actual behavior
The test fails: The Bash command breaks due to syntax errors, and the exit code is nonzero.
Due to lack of support for single-quoted strings, PowerShell passes the following arguments to bash (enclosed in [...] here to show their boundaries):
[-c]
['echo]
[$1 $RANDOM']
[-]
['I'\''m']
Note how the '...' argument was broken in two, and how the embedded double quotes disappeared.
I've closed this issue, because I remembered that a decision was made in #3733 (comment) that --% will not be extended to work more sensibly on Unix-like platform.
I've created a documentation issue instead, asking that the near-uselessness of --% on Unix be documented: MicrosoftDocs/PowerShell-Docs#4963
If you know --%'s limitations, you can still use it, however, so in the command that prompted #10219 you can simply use ssh-keygen --% "", i.e. double quotes.
Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-DuplicateThe issue is a duplicate.
Activity
mklement0 commentedon Oct 18, 2019
Thanks, chuanjiao10.
I've closed this issue, because I remembered that a decision was made in #3733 (comment) that
--%will not be extended to work more sensibly on Unix-like platform.I've created a documentation issue instead, asking that the near-uselessness of
--%on Unix be documented: MicrosoftDocs/PowerShell-Docs#4963If you know
--%'s limitations, you can still use it, however, so in the command that prompted #10219 you can simply usessh-keygen --% "", i.e. double quotes.