Skip to content

Commit

Permalink
child_process: throw exception for batch w/o shell
Browse files Browse the repository at this point in the history
  • Loading branch information
RedYetiDev committed Apr 25, 2024
1 parent d5c7ffd commit 9063f08
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/internal/child_process.js
Expand Up @@ -11,6 +11,7 @@ const {
ObjectSetPrototypeOf,
ReflectApply,
StringPrototypeSlice,
StringPrototypeToLowerCase,
Symbol,
SymbolDispose,
Uint8Array,
Expand Down Expand Up @@ -61,6 +62,7 @@ const { isArrayBufferView } = require('internal/util/types');
const spawn_sync = internalBinding('spawn_sync');
const { kStateSymbol } = require('internal/dgram');
const dc = require('diagnostics_channel');
const { extname } = require('path');
const childProcessChannel = dc.channel('child_process');

const {
Expand Down Expand Up @@ -418,7 +420,12 @@ ChildProcess.prototype.spawn = function(options) {

this._handle.close();
this._handle = null;
throw new ErrnoException(err, 'spawn');
const exception = new ErrnoException(err, 'spawn');
const ext = StringPrototypeToLowerCase(extname(options.file));
if (ext === '.cmd' || ext === '.bat') {
exception.message = '"shell" must be "true" when spawning ' +
'a batch executable';
}
} else {
process.nextTick(onSpawnNT, this);
}
Expand Down

0 comments on commit 9063f08

Please sign in to comment.