| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 72fc4eb commit 9bb1024
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -489,7 +489,7 @@ function execFileSync(/*command, args, options*/) { | |||
| 489 | 489 | ||
| 490 | 490 | var ret = spawnSync(opts.file, opts.args.slice(1), opts.options); | |
| 491 | 491 | ||
| 492 | - if (inheritStderr) | ||
| 492 | + if (inheritStderr && ret.stderr) | ||
| 493 | 493 | process.stderr.write(ret.stderr); | |
| 494 | 494 | ||
| 495 | 495 | var err = checkExecSyncError(ret); | |
@@ -509,7 +509,7 @@ function execSync(command /*, options*/) { | |||
| 509 | 509 | var ret = spawnSync(opts.file, opts.options); | |
| 510 | 510 | ret.cmd = command; | |
| 511 | 511 | ||
| 512 | - if (inheritStderr) | ||
| 512 | + if (inheritStderr && ret.stderr) | ||
| 513 | 513 | process.stderr.write(ret.stderr); | |
| 514 | 514 | ||
| 515 | 515 | var err = checkExecSyncError(ret); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,6 +12,18 @@ var start = Date.now(); | |||
| 12 | 12 | var err; | |
| 13 | 13 | var caught = false; | |
| 14 | 14 | ||
| 15 | + // Verify that stderr is not accessed when a bad shell is used | ||
| 16 | + assert.throws( | ||
| 17 | + function() { execSync('exit -1', {shell: 'bad_shell'}); }, | ||
| 18 | + /spawnSync bad_shell ENOENT/, | ||
| 19 | + 'execSync did not throw the expected exception!' | ||
| 20 | + ); | ||
| 21 | + assert.throws( | ||
| 22 | + function() { execFileSync('exit -1', {shell: 'bad_shell'}); }, | ||
| 23 | + /spawnSync bad_shell ENOENT/, | ||
| 24 | + 'execFileSync did not throw the expected exception!' | ||
| 25 | + ); | ||
| 26 | + | ||
| 15 | 27 | try { | |
| 16 | 28 | var cmd = `"${process.execPath}" -e "setTimeout(function(){}, ${SLEEP});"`; | |
| 17 | 29 | var ret = execSync(cmd, {timeout: TIMER}); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments