Closed
Description
- Version: 7.2.0 (all?)
- Platform: Windows
- Subsystem: Child Process
On Posix:
test file:
#!/usr/bin/env bash
echo "hello"
$ chmod 755 test
node
> var cp = require('child_process')
undefined
> cp.spawnSync('test')
'hello\n'
>
On Windows:
test.cmd file:
echo "hello"
$ echo %PATHEXT%
.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
node
> var cp = require('child_process')
undefined
> cp.spawnSync('test')
null
> cp.spawnSync('test.cmd')
null
> cp.spawnSync('test', {shell:true})
'hello\n'
Windows uses PATHEXT, ASSOC, and FTYPE to achieve something similar to Posix using execute permission and shebangs.
On Windows, spawn()
is not giving Windows a chance to query PATHEXT, ASSOC, FTYPE information to run test.cmd
as an executable.
To fix, on Windows, spawn()
should always launch using CMD
, when {shell:undefined}
(i.e. set it to true when undefined), so that CMD can correctly handle PATHEXT, ASSOC, and FTYPE configuration. This does mean real
, binary executables won't be launched directly but this should have no perceivable impact on launch time or behavior. The benefit is increased parity between Posix and Windows behavior.