Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: Exit 1 with empty string if no match#901

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
nfischer merged 1 commit intoshelljs:masterfromwyardley:wyardley-issue_900_grep
Nov 13, 2018
Merged

fix: Exit 1 with empty string if no match#901

nfischer merged 1 commit intoshelljs:masterfromwyardley:wyardley-issue_900_grep
Nov 13, 2018

Conversation

wyardley
Copy link
Contributor

@wyardleywyardley commentedNov 8, 2018
edited
Loading

Resolve an issue where grep returned 0 (with a\n as the output), even when the regex doesn't match.

Fixes#900

@wyardley
Copy link
ContributorAuthor

wyardley commentedNov 8, 2018
edited
Loading

@nfischer
The failure is on those other two test cases on line 39 and 48; seems to be returning both the original error, and the new one, even with that explicit return.

   38:   t.truthy(shell.error());                                             39:   t.is(result.stderr, 'grep: no such file or directory: /asdfasdf');   40:   t.is(result.code, 2);                                               Difference:  - `grep: no such file or directory: /asdfasdf␊  - grep: `  + `grep: no such file or directory: /asdfasdf

@nfischer
Copy link
Member

@wyardley can you add "Fixes#900" to the PR description?

Copy link
Member

@nfischernfischer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Looks pretty close so far. Let me know if explanations make sense, since we don't have much documentation on thesecommon APIs.

@wyardleywyardley changed the titlefix: Exit 1 with empty string if no match (#900)fix: Exit 1 with empty string if no matchNov 8, 2018
t.is(result.toString(),'this line ends in.js\nlllllllllllllllll.js\n');
});

test("one file, pattern doesn't match",t=>{
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Do you want this under 'valids' or 'invalids?
Even though it's a non-0 exit code, I would personally consider testing for the absence of something to be a "valid" use case, but I'm happy to move it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This spot LGTM

@wyardley
Copy link
ContributorAuthor

wyardley commentedNov 8, 2018
edited
Loading

@nfischer Ok, how's that look. I added another test case for the specific case where there are two files, one which dne and the other of which doesn't match. I can move this to the "Invalids" section if you think that's better (see above)...

@codecov-io
Copy link

codecov-io commentedNov 8, 2018
edited
Loading

Codecov Report

Merging#901 intomaster willincrease coverage by<.01%.
The diff coverage is100%.

Impacted file tree graph

@@            Coverage Diff             @@##           master     #901      +/-   ##==========================================+ Coverage   97.32%   97.32%   +<.01%==========================================  Files          34       34                Lines        1269     1271       +2     ==========================================+ Hits         1235     1237       +2  Misses         34       34
Impacted FilesCoverage Δ
src/grep.js100% <100%> (ø)⬆️

Continue to review full report at Codecov.

Legend -Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing data
Powered byCodecov. Last update6b3c7b1...163e049. Read thecomment docs.

Copy link
Member

@nfischernfischer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

LGTM % suggestions

t.is(result.toString(),'this line ends in.js\nlllllllllllllllll.js\n');
});

test("one file, pattern doesn't match",t=>{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This spot LGTM

When we can read all files, but none match, exit 1 and return no output. Thismatches the behavior of grep more closely.Fixes#900
@wyardley
Copy link
ContributorAuthor

@nfischer applied your suggestions and squashed

@nfischernfischer added the fixBug/defect, or a fix for such a problem labelNov 9, 2018
@nfischer
Copy link
Member

Thanks. I'll merge this after I push a release (this probably constitutes a breaking change).

@nfischernfischer merged commit5da1dda intoshelljs:masterNov 13, 2018
@wyardleywyardley deleted the wyardley-issue_900_grep branchNovember 13, 2018 05:37
@Nel75
Copy link

Nel75 commentedApr 6, 2021
edited
Loading

Hi. This fix is still not available on the latest releasev0.8.4, despite being on the master branch (https://github.com/shelljs/shelljs/blob/master/src/grep.js#L72-L75). What is its status? Was there an issue with its packaging? This fix is really needed, as the current grep implementation is broken - I would argue it's a fixing change rather than a breaking one, as anyone relying on exit code 1 to detect the absence of matches is currently broken. Thanks.

@nfischernfischer added this to thev0.9.0 milestoneApr 6, 2021
@nfischernfischer added the breakingBreaking change labelApr 6, 2021
@nfischer
Copy link
Member

I think this landed after v0.8.3 went out. v0.8.4 was a small patch release for a specific bug, which is why this didn't make it in that release either.

I've updated the milestone field to clarify this is expected to be part of v0.9.0. I haven't had time to figure out what needs to make it in that release and what should be punted to the next release.

@Nel75
Copy link

@nfischer Thanks for the quick reply. Any idea when v0.9.0 might be released? It's been over 2 years now since this fix, so I'll have to use another script in the mean time.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nfischernfischernfischer approved these changes

Assignees

No one assigned

Labels

breakingBreaking changefixBug/defect, or a fix for such a problem

Projects

None yet

Milestone

v0.9.0

Development

Successfully merging this pull request may close these issues.

grep exit status and extra newlines

4 participants

@wyardley@nfischer@codecov-io@Nel75

[8]ページ先頭

©2009-2025 Movatter.jp