Skip to content

Commit

Permalink
grep -F versus stdin (#641)
Browse files Browse the repository at this point in the history
* 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)
  • Loading branch information
mknos committed Jun 5, 2024
1 parent 036b22f commit caf4f5f
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions bin/grep
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ sub parse_args {
}
@patterns = ($pattern);
}
@ARGV = ($opt{'r'} ? '.' : '-') unless @ARGV;

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

@ARGV = ( $opt{r} ? '.' : '-' ) unless @ARGV;

$match_code .= 'study;' if @patterns > 5; # might speed things up a bit

foreach (@patterns) {s(/)(\\/)g}
Expand Down

0 comments on commit caf4f5f

Please sign in to comment.