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

shx grep -v adds extra newline #163

Open
backspaces opened this issue Jul 2, 2019 · 1 comment
Open

shx grep -v adds extra newline #163

backspaces opened this issue Jul 2, 2019 · 1 comment

Comments

@backspaces
Copy link

Certain uses of grep appear to add extra newlines.

Ex:
Try something like this:

shx ls '~/Music/iTunes' | shx grep 'iTunes'

It acts as expected, producing strings with a single \n for each line.

But

shx ls '~/Music/iTunes' | shx grep '-v' 'iTunes'

appears to add a second newline at the end of the set of strings.

This can be explicitly seen in node:

var sh = require('shelljs')
// terminates with a single newline
sh.ls('~/Music/iTunes').grep('iTunes')
// terminates with two newlines
sh.ls('~/Music/iTunes').grep('-v', 'iTunes')
@nfischer
Copy link
Member

nfischer commented Jul 3, 2019

Yeah, I can repro. Seems like a bug in grep() rather than ls().

shx ls | shx grep -v 'foo' # bug
shx ls | grep -v 'foo'     # no bug
ls | shx grep -v 'foo'     # bug
ls | grep -v 'foo'         # no bug

PRs are welcome for https://github.com/shelljs/shelljs (it seems the bug is there, rather than in this project).

@nfischer nfischer added the fix label Jul 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants