Skip to content

Commit caf4f5f

Browse files
authored
grep -F versus stdin (#641)
* ARGV list was supposed to have the value '-' added if it was empty * I noticed that grep would simply exit for the following test: echo hello1 | perl grep -F 1 * In this usage the argument "1" is shifted off ARGV list and the code to reset ARGV was happening too late (problem caused by recent grep -F code addition)
1 parent 036b22f commit caf4f5f

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

bin/grep

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ sub parse_args {
176176
}
177177
@patterns = ($pattern);
178178
}
179+
@ARGV = ($opt{'r'} ? '.' : '-') unless @ARGV;
179180

180181
if ( $opt{H} || $opt{u} ) { # highlight or underline
181182
my $term = $ENV{TERM} || 'vt100';
@@ -244,8 +245,6 @@ sub parse_args {
244245
$opt{c} += $opt{C};
245246
$opt{1} += $opt{'s'} && !$opt{c}; # that's a one
246247

247-
@ARGV = ( $opt{r} ? '.' : '-' ) unless @ARGV;
248-
249248
$match_code .= 'study;' if @patterns > 5; # might speed things up a bit
250249

251250
foreach (@patterns) {s(/)(\\/)g}

0 commit comments

Comments
 (0)