From d1463319e5b2447d9028cf46e697238e03dab419 Mon Sep 17 00:00:00 2001 From: Michael Mikonos <127171689+mknos@users.noreply.github.com> Date: Wed, 29 May 2024 14:59:27 +0800 Subject: [PATCH] grep -f 0 * It is valid for a pattern file to be named "0" but this was not being ignored by grep %cat > 0 main puts ^D %perl grep -nf 0 a.c 4:main(void) 6: puts("yo"); --- bin/grep | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/grep b/bin/grep index 9b88a066..1f1864ed 100755 --- a/bin/grep +++ b/bin/grep @@ -146,7 +146,7 @@ sub parse_args { my $no_re = $opt{F} || ( $Me =~ /\bfgrep\b/ ); - if ( $opt{f} ) { # -f patfile + if (defined $opt{'f'}) { # -f patfile die("$Me: $opt{f}: is a directory\n") if ( -d $opt{f} ); open PATFILE, '<', $opt{f} or die qq($Me: Can't open '$opt{f}': $!);