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

silent does not always work #851

Closed
GuyMograbi opened this issue May 16, 2018 · 6 comments
Closed

silent does not always work #851

GuyMograbi opened this issue May 16, 2018 · 6 comments
Assignees
Labels
fix Bug/defect, or a fix for such a problem medium priority

Comments

@GuyMograbi
Copy link

node 8.9.1
shelljs 0.8.1
mac osx

I expect this code to not produce any output but it does.

const shell = require('shelljs');

shell.exec('git rev-parse --abbrev-ref  master2@{upstream}', {silent:true});

Run it in a git repository that does not have a branch master2 and you should see an error printed

exec: fatal: no such branch: 'master2'
@nfischer
Copy link
Member

Thanks for reporting. I can repro:

> exec('ls somefakefilethatdoesntexist')
ls: cannot access 'somefakefilethatdoesntexist': No such file or directory
exec: ls: cannot access 'somefakefilethatdoesntexist': No such file or directory

> exec('ls somefakefilethatdoesntexist', { silent: true })
exec: ls: cannot access 'somefakefilethatdoesntexist': No such file or directory

This is a regression after v0.7.x. We should not output the lines with the exec prefix. I'll try to write up a quick fix.

@nfischer nfischer self-assigned this May 17, 2018
@nfischer nfischer added fix Bug/defect, or a fix for such a problem medium priority labels May 17, 2018
@uttpal
Copy link
Contributor

uttpal commented Jun 22, 2018

@nfischer Hey, can I try to fix this issue?

@nfischer
Copy link
Member

@uttpal sure thing. This issue fell off my radar.

@nfischer nfischer removed their assignment Jun 22, 2018
uttpal pushed a commit to uttpal/shelljs that referenced this issue Jun 23, 2018
@uttpal
Copy link
Contributor

uttpal commented Jun 23, 2018

@nfischer I raised a pr can you take a look, thanks!

@RamyRais
Copy link

when can we have the PR merged?

@nfischer
Copy link
Member

@RamyRais the PR should be good, but I want to fix CI first. I'll try to work on this.

@nfischer nfischer self-assigned this Oct 24, 2018
nfischer added a commit that referenced this issue Oct 27, 2018
Unconditionally apply `silent: true` when calling `common.error()` from
`exec()`. This is because errors are already printed to stderr, or are
intentionally silenced by `shell.config.silent`.

Based on #861 

Fixes #851
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 medium priority
Projects
None yet
Development

No branches or pull requests

4 participants