From 94bb1ac5fad5b04ea1c63af5586525859b8afc52 Mon Sep 17 00:00:00 2001 From: Michael Mikonos <127171689+mknos@users.noreply.github.com> Date: Mon, 18 Nov 2024 07:19:35 +0800 Subject: [PATCH] grep: remove paragraph mode * Remove options -p and -P, which don't correspond with any other version of grep * Standard grep would require formatting paragraph onto one line first before feeding it to grep --- bin/grep | 59 +++++++++++++++----------------------------------------- 1 file changed, 16 insertions(+), 43 deletions(-) diff --git a/bin/grep b/bin/grep index 79b08790..fabbfff5 100755 --- a/bin/grep +++ b/bin/grep @@ -54,7 +54,7 @@ use File::Spec; use File::Temp qw(); use Getopt::Std; -our $VERSION = '1.015'; +our $VERSION = '1.016'; $| = 1; # autoflush output @@ -88,8 +88,8 @@ sub VERSION_MESSAGE { sub usage { die <{'A'}; } } - if ( $opt->{p} || $opt->{P} ) { - s/\n{2,}$/\n/ if $opt->{p}; - chomp if $opt->{P}; - } if ($opt->{'l'}) { print $name, "\n"; last LINE; @@ -525,9 +512,6 @@ FILE: while ( defined( $file = shift(@_) ) ) { } } print $_; - if ($opt->{'p'} || $opt->{'P'}) { - print ('-' x 20), "\n"; - } } if ($ctx_a == 0 && !$Matches) { print "--\n"; @@ -560,12 +544,12 @@ grep - search for regular expressions and print =head1 SYNOPSIS - grep [-IincwsxvhHlLFigurpaqT] [-e pattern] [-A NUM] [-B NUM] [-C NUM] - [-m NUM] [-f pattern-file] [-P sep] [pattern] [file ...] + grep [-IincwsxvhHlLFiguraqT] [-e pattern] [-A NUM] [-B NUM] [-C NUM] + [-m NUM] [-f pattern-file] [pattern] [file ...] =head1 DESCRIPTION -B searches for lines (or, optionally, paragraphs) in files +B searches for lines in files that satisfy the criteria specified by the user-supplied patterns. Because this B is a Perl program, the user has full access to Perl's rich regular expression engine. See L. @@ -605,7 +589,7 @@ Display NUM lines of context surrounding each matching line. =item B<-c> -Output the count of the matching lines or paragraphs. +Output only the count of the matching lines. =item B<-e> I @@ -632,17 +616,17 @@ the B<-f> option supercedes the B<-e> option. Highlight matches. This option causes B to attempt to use your terminal's stand-out (emboldening) functionality to highlight -those portions of each matching line or paragraph that actually +those portions of each matching line that actually triggered the match. This feature is very similar to the way the less(1) pager highlights matches. See also B<-u>. =item B<-H> -Always include filename headers for matching lines or paragraphs. +Always include filename headers for matching lines. =item B<-h> -Hide filenames. Only print matching lines or paragraphs. +Hide filenames. Only print matching lines. =item B<-I> @@ -668,21 +652,10 @@ This option implies the B<-1> option. =item B<-n> -Number lines or paragraphs. Before outputting a given match, B -will first output its line or paragraph number corresponding to the +Number lines. Before outputting a given match, B +will first output its line corresponding to the value of the Perl magic scalar $. (whose documentation is in L). -=item B<-P> I - -Put B in paragraph mode, and use I as the paragraph -separator. This is implemented by assigning I to Perl's magic -$/ scalar. See L. - -=item B<-p> - -Paragraph mode. This causes B to set Perl's magic $/ to C<''>. -(Note that the default is to process files in line mode.) See L. - =item B<-s> Suppress diagnostic messages to the standard error. @@ -715,12 +688,12 @@ when opening a file for searching Underline matches. This option causes B to attempt to use your terminal's underline functionality to underline those portions of -each matching line or paragraph that actually triggered the match. +each matching line that actually triggered the match. See also B<-H>. =item B<-v> -Invert the sense of the match, i.e. print those lines or paragraphs +Invert the sense of the match, i.e. print those lines that do B match. When using this option in conjunction with B<-f>, keep in mind that the entire set of patterns are grouped together in one pattern for the purposes of negation. See L<"EXAMPLES">. @@ -734,7 +707,7 @@ for the precise definition of C<\b>. =item B<-x> -Exact matches only. The pattern must match the entire line or paragraph. +Exact matches only. The pattern must match the entire line. =item B<-Z>