grep: Fix -f FILE when FILE is empty and -x provided

Grep currently special-cased empty pattern file to be the same as
pattern file with one empty line (empty pattern). That does mirror how
GNU grep behaves, except when -x is provided. In that case .* pattern
needs to be used instead.

Signed-off-by: Gray Wolf <wolf@wolfsden.cz>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Gray Wolf
2020-04-29 15:49:17 +02:00
committed by Denys Vlasenko
parent 1c462d47a0
commit c3295d233b
2 changed files with 9 additions and 2 deletions

View File

@@ -129,6 +129,12 @@ testing "grep -v -f EMPTY_FILE" \
"" \
"test\n"
testing "grep -vxf EMPTY_FILE" \
"grep -vxf input" \
"test\n" \
"" \
"test\n"
testing "grep -Fw matches only words" \
"grep -Fw foo input" \
"" \