Skip to content

shell.exec() doesn't respond correctly to config.fatal = true #735

@nfischer

Description

@nfischer

Node version (or tell us if you're using electron or some other framework):

all

ShellJS version (the most recent version/Github branch you see the bug on):

master

Operating system:

all

Description of the bug:

Setting config.fatal = true messes up shell.exec(). When config.fatal is true, we throw an exception from common.error(). Unfortunately, this gets caught by ShellJS and is treated like an internal error, which isn't correct.

Example ShellJS command to reproduce the error:

> shell.config.fatal = true;
> shell.exec('cmd_that_fails');
Error: exec: internal error
    at Object.error (/path/to/shelljs/src/common.js:130:27)
    at Object._exec (/path/to/shelljs/src/exec.js:292:12)
    at Object.exec (/path/to/shelljs/src/common.js:334:23)
    at repl:1:3
    at sigintHandlersWrap (vm.js:22:35)
    at sigintHandlersWrap (vm.js:96:12)
    at ContextifyScript.Script.runInThisContext (vm.js:21:12)
    at REPLServer.defaultEval (repl.js:313:29)
    at bound (domain.js:280:14)
    at REPLServer.runBound [as eval] (domain.js:293:12)
> // the exception is expected to contain the command's stderr

Metadata

Metadata

Assignees

Labels

execIssues specific to the shell.exec() APIfixBug/defect, or a fix for such a problemstability

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions