Page MenuHomeFreeBSD

bsdgrep(1): Don't exit before processing every file
ClosedPublic

Authored by kevans on Jul 22 2017, 11:13 PM.
Tags
None
Referenced Files
Unknown Object (File)
Oct 2 2024, 5:48 AM
Unknown Object (File)
Sep 29 2024, 2:53 AM
Unknown Object (File)
Sep 24 2024, 9:54 AM
Unknown Object (File)
Sep 24 2024, 9:10 AM
Unknown Object (File)
Sep 24 2024, 3:17 AM
Unknown Object (File)
Sep 23 2024, 10:59 PM
Unknown Object (File)
Sep 21 2024, 3:51 PM
Unknown Object (File)
Sep 19 2024, 11:59 PM
Subscribers

Details

Summary

Given an empty pattern (i.e. grep "" A B), bsdgrep(1)
would previously exit() with the appropriate error code upon
encountering an empty file. Likely intended as an optimization,
but this behavior is technically incorrect since an empty pattern
should match every line.

PR: 220924

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

This revision is now accepted and ready to land.Jul 22 2017, 11:25 PM
usr.bin/grep/util.c
264 ↗(On Diff #31091)

Doesn't this imply that an empty pattern matches once in an empty file?

usr.bin/grep/util.c
264 ↗(On Diff #31091)

...right, still not correct behavior. Now that I reread this block, it should also do the wrong thing with printf "\nA" | grep "" and omit the second line.

I'll amend the test for both the problem you mentioned and this one.

usr.bin/grep/util.c
264 ↗(On Diff #31091)

Nope, misread again. Drats

kevans edited edge metadata.

Empty files tell no tales nor do they match an empty string

This revision now requires review to proceed.Jul 25 2017, 1:04 AM
This revision is now accepted and ready to land.Jul 25 2017, 1:06 AM
This revision was automatically updated to reflect the committed changes.