- Notifications
You must be signed in to change notification settings - Fork741
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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
wyardley commentedNov 8, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@nfischer
|
There was a problem hiding this 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.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
t.is(result.toString(),'this line ends in.js\nlllllllllllllllll.js\n'); | ||
}); | ||
test("one file, pattern doesn't match",t=>{ |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This spot LGTM
wyardley commentedNov 8, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@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 commentedNov 8, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Codecov Report
@@ Coverage Diff @@## master #901 +/- ##==========================================+ Coverage 97.32% 97.32% +<.01%========================================== Files 34 34 Lines 1269 1271 +2 ==========================================+ Hits 1235 1237 +2 Misses 34 34
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
LGTM % suggestions
Uh oh!
There was an error while loading.Please reload this page.
t.is(result.toString(),'this line ends in.js\nlllllllllllllllll.js\n'); | ||
}); | ||
test("one file, pattern doesn't match",t=>{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This spot LGTM
Uh oh!
There was an error while loading.Please reload this page.
When we can read all files, but none match, exit 1 and return no output. Thismatches the behavior of grep more closely.Fixes#900
@nfischer applied your suggestions and squashed |
Thanks. I'll merge this after I push a release (this probably constitutes a breaking change). |
Nel75 commentedApr 6, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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. |
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 commentedApr 9, 2021
@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. |
Uh oh!
There was an error while loading.Please reload this page.
Resolve an issue where grep returned 0 (with a
\n
as the output), even when the regex doesn't match.Fixes#900