-
Notifications
You must be signed in to change notification settings - Fork 29.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request:child_process.exec for powershell #21905
Comments
The current behvior is well understood and backed up by documentation:
However, I see it is reasonable to accommodate powershell. cc @nodejs/child_process in case if anyone has concerns. @tkamenoko - are you willing to contribute through a PR? |
Related: #19947 |
Yes, I want to contribute! Well, I have 2 questions before coding. Thanks. |
awesome, thanks!
test/parallel/test-chilld-process-*
would be great if you can cover git-bash too, while we are here. |
Thank you for the advice. I'll start working. |
On Windows, normalizeSpawnArguments set "/d /s /c" for any shells. It cause exec and other methods are limited to cmd.exe as a shell. Powershell and git-bash are often used instead of cmd.exe, and they can recieve "-c" switch like unix shells. So normalizeSpawnArguments is changed to set "/d /s /c" for cmd.exe, and "-c" for others. Fixes: nodejs#21905
On Windows, normalizeSpawnArguments set "/d /s /c" for any shells. It cause exec and other methods are limited to cmd.exe as a shell. Powershell and git-bash are often used instead of cmd.exe, and they can recieve "-c" switch like unix shells. So normalizeSpawnArguments is changed to set "/d /s /c" for cmd.exe, and "-c" for others. Fixes: nodejs#21905
On Windows, normalizeSpawnArguments set "/d /s /c" for any shells. It cause exec and other methods are limited to cmd.exe as a shell. Powershell and git-bash are often used instead of cmd.exe, and they can recieve "-c" switch like unix shells. So normalizeSpawnArguments is changed to set "/d /s /c" for cmd.exe, and "-c" for others. Fixes: nodejs#21905
On Windows,
child_process.exec
(or other methods) supports only cmd.exe as the shell, so running the following shows error messages.result:
However, there are alternate shells like powershell, git-bash, etc. So I suggest to fix the behavior.
I suppose the cause is this code(a part of
child_process.normalizeSpawnArguments
):node/lib/child_process.js
Lines 469 to 479 in c3f8dd6
On Windows, it sets
/d /s /c
for args even ifoptions.shell!=="cmd.exe"
. Powershell can receive-c
option like unix shells, so/d /s /c
should be used for only cmd.exe.The text was updated successfully, but these errors were encountered: