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)
Dec 20 2023, 2:05 AM
Unknown Object (File)
Dec 17 2023, 10:48 PM
Unknown Object (File)
Sep 30 2023, 1:36 PM
Unknown Object (File)
Sep 21 2023, 5:31 PM
Unknown Object (File)
Sep 3 2023, 11:40 AM
Unknown Object (File)
Jul 14 2023, 7:02 AM
Unknown Object (File)
Jun 21 2023, 2:13 AM
Unknown Object (File)
May 20 2023, 4:21 AM
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.