Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

grep: add -R alias for -r #820

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions bin/grep
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ use File::Spec;
use File::Temp qw();
use Getopt::Std;

our $VERSION = '1.016';
our $VERSION = '1.017';

$| = 1; # autoflush output

Expand Down Expand Up @@ -88,7 +88,7 @@ sub VERSION_MESSAGE {

sub usage {
die <<EOF;
usage: $Me [-IincwsxvHhLlFguraqT] [-e pattern] [-A NUM] [-B NUM] [-C NUM]
usage: $Me [-IincwsxvHhLlFguRraqT] [-e pattern] [-A NUM] [-B NUM] [-C NUM]
[-m NUM] [-f pattern-file] [pattern] [file...]

Options:
Expand Down Expand Up @@ -243,8 +243,9 @@ sub parse_args {
}
@ARGV = @tmparg;

getopts('IinC:cwsxvHhLlguraqTFZm:A:B:', \%opt) or usage();
getopts('IinC:cwsxvHhLlguRraqTFZm:A:B:', \%opt) or usage();

$opt{'r'} ||= $opt{'R'};
if (defined $opt{'m'} && $opt{'m'} !~ m/\A[0-9]+\z/) {
die "$Me: invalid max count\n";
}
Expand All @@ -261,6 +262,7 @@ sub parse_args {

unless (length $pattern) {
$pattern = shift @ARGV;
usage() unless defined $pattern;
push @patterns, $pattern;
}
unless ($no_re) {
Expand Down Expand Up @@ -544,7 +546,7 @@ grep - search for regular expressions and print

=head1 SYNOPSIS

grep [-IincwsxvhHlLFiguraqT] [-e pattern] [-A NUM] [-B NUM] [-C NUM]
grep [-IincwsxvhHlLFiguRraqT] [-e pattern] [-A NUM] [-B NUM] [-C NUM]
[-m NUM] [-f pattern-file] [pattern] [file ...]

=head1 DESCRIPTION
Expand Down Expand Up @@ -660,7 +662,7 @@ value of the Perl magic scalar $. (whose documentation is in L<perlvar>).

Suppress diagnostic messages to the standard error.

=item B<-r>
=item B<-R> and B<-r>

Recursively scan directories. This option causes B<grep> to
descend directories in a left-first, depth-first manner and search
Expand Down
Loading