promise-spawn
promise-spawn copied to clipboard
[BUG] `spawnWithShell` is very, very broken on Windows
Is there an existing issue for this?
- [X] I have searched the existing issues
Current Behavior
There are multiple significant issues with spawnWithShell
on Windows:
-
It finds the executable by looking at the string and naively scanning for quotes. This doesn't respect
^
-escaped spaces. -
This quote-scanning doesn't match types of quotes. For instance,
"'my double quoted path'"
will open quotes at the first"
character and then say the quotes have ended at the'
character. -
Finally, the path is passed to
which.sync
with the quotes intact. So it's looking for an executable with those quotes in its path. -
The
isCmd
regex searches for\
but/
is a legal alternative path separator on windows. -
Shell can be passed in. It's not unlikely that, if the user is on Windows, they're using PowerShell. In that case, I don't know what's supposed to happen.
Originally reported at https://github.com/npm/cli/issues/6716#issuecomment-1684566375