shelljs / shelljs/shx

shx grep -v adds extra newline

Open
#163 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

fix shelljs
Dominant language
JavaScript
Stars
1.9k
Forks
51
Avg merge
3d 2h
Merged PRs (30d)
1

Description

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')

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the behavior with the two shx grep command forms in the issue, then compare it with the shown shelljs grep calls. Trace the shx grep entry point and verify that both positive and -v filtering end with only the expected single newline.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, shell
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.