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: retire -t extension #748

Merged
merged 1 commit into from
Sep 30, 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
24 changes: 5 additions & 19 deletions bin/grep
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ use File::Basename qw(basename);
use File::Spec;
use Getopt::Std;

our $VERSION = '1.005';
our $VERSION = '1.006';

$| = 1; # autoflush output

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

sub usage {
die <<EOF;
usage: $Me [-inCcwsxvHhLlF1gurtpaqT] [-e pattern]
usage: $Me [-inCcwsxvHhLlF1gurpaqT] [-e pattern]
[-f pattern-file] [-P sep] [pattern] [file...]

Options:
Expand All @@ -110,7 +110,6 @@ Options:
-g highlight matches
-u underline matches
-r recursive on directories or dot if none
-t process directories in `ls -t` order
-p paragraph mode (default: line mode)
-P ditto, but specify separator, e.g. -P '%%\\n'
-a all files, not just plain text files
Expand All @@ -132,7 +131,7 @@ sub parse_args {
}

$opt{'p'} = $opt{'P'} = ''; # argument to print()
getopts('inCcwsxvHhe:f:Ll1gurtpP:aqTF', \%opt) or usage();
getopts('inCcwsxvHhe:f:Ll1gurpP:aqTF', \%opt) or usage();

$opt{'l'} = 0 if $opt{'L'};
my $no_re = $opt{F} || ( $Me =~ /\bfgrep\b/ );
Expand Down Expand Up @@ -323,14 +322,7 @@ FILE: while ( defined( $file = shift(@_) ) ) {
push @list, File::Spec->catfile($file, $_);
}
closedir $dh;
if ( $opt->{t} ) {
my (@dates);
for (@list) { push( @dates, -M ) }
@list = @list[ sort { $dates[$a] <=> $dates[$b] } 0 .. $#dates ];
}
else {
@list = sort @list;
}
@list = sort @list;
matchfile( $opt, $matcher, @list ); # process files
next FILE;
}
Expand Down Expand Up @@ -433,7 +425,7 @@ grep - search for regular expressions and print

=head1 SYNOPSIS

B<grep> [ B<-[incCwsxvhHlLF1igurtpaqT]> ] [ B<-e> I<pattern> ]
B<grep> [ B<-[incCwsxvhHlLF1igurpaqT]> ] [ B<-e> I<pattern> ]
[ B<-f> I<pattern-file> ] [ B<-P> I<sep> ] [ I<pattern> ] [ I<files> ... ]

=head1 DESCRIPTION
Expand Down Expand Up @@ -575,12 +567,6 @@ when skipping non-plain files (see L<perlfunc/-f>),
when skipping non-text files (see L<perlfunc/-T>), and
when opening a file for searching

=item B<-t>

Process directories in C<`ls -t`> order. Search the files in each
directory starting with the most recently modified and ending with
the least recently modified.

=item B<-u>

Underline matches. This option causes B<grep> to attempt to use
Expand Down
Loading