Skip to content
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

Where is standard error going to? #209

Closed
guiprav opened this issue Jun 12, 2015 · 3 comments
Closed

Where is standard error going to? #209

guiprav opened this issue Jun 12, 2015 · 3 comments
Assignees
Labels
fix Bug/defect, or a fix for such a problem

Comments

@guiprav
Copy link

guiprav commented Jun 12, 2015

If I run:

console.log(sh.exec('echo WHOA THERE, AN ERROR CONDITION... 1>&2'));
console.log(sh.error());

I get:

WHOA THERE, AN ERROR CONDITION...
{ code: 0, output: '' }
null

So how do I get messages from standard error in JavaScript?

@nfischer
Copy link
Member

I think there might be a few problems going on here that might need updating. I get very different behavior depending on which commands I run:

$ cat test.js
require('shelljs/global');
exec('echo stdout is showing');
exec('echo stderr is showing >&2');

$ node test.js >/dev/null
stderr is showing

$ node test.js 2>/dev/null
stdout is showing

$ shjs test.js >/dev/null

$ shjs test.js 2>/dev/null
stdout is showing
stderr is showing

This suggests that something is at least broken in the shjs script if not somewhere else as well. I suspect that this is related, and points toward a bug related to the exec() function (shjs is essentially a wrapper for a call to exec('node ' + script_name + args); (see here).

I suspect it should just be modified to support capturing a process's stderr in addition to its stdout, and have both of these returned alongside the return code.

@nfischer
Copy link
Member

This was bugging me, so I added this to #268. @n2liquid does this help you achieve what you wanted?

@ariporad ariporad added the fix Bug/defect, or a fix for such a problem label Jan 9, 2016
@nfischer
Copy link
Member

Closing this, since #268 was merged. If this doesn't work as expected, please reopen this issue and let us know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Bug/defect, or a fix for such a problem
Projects
None yet
Development

No branches or pull requests

3 participants