From 29c35ba17c7a73fe495dc87d2d16e6fef2231065 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Sun, 2 Feb 2025 16:00:34 -0500 Subject: bsgrep: fix double newlines from File::Find warnings; commentary; docs. --- bsgrep | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/bsgrep b/bsgrep index 0f33e16..65d138c 100755 --- a/bsgrep +++ b/bsgrep @@ -11,13 +11,20 @@ use File::Find; $SIG{__WARN__} = sub { my $m = shift; + + # don't include the line number in warnings. $m =~ s/ at \S+ line \d+\.$//; + + # File::Find seems to use double newlines for its warnings.. + $m =~ s/\n\n+/\n/; + # warnings that don't start with $self: are e.g. file access errors - # from the 'while(<>)'. + # from the 'while(<>)' or File::Find. if($m !~ /^$self:/) { $m = "$self: $m"; $ret = 2 unless $opt{s}; } + print STDERR $m unless $opt{s}; }; @@ -171,10 +178,10 @@ bsjoin B<[-hvlkinrws]> [I I<...>] =head1 DESCRIPTION -B searches uses a regular expression to search for strings -in a file, much like B(1). The difference is, B joins -together lines that use the backslash for continuation (e.g. as -B(1) does). +B (backslash grep) uses a regular expression to search for +strings in a file, much like B(1). The main difference is, +B joins together lines that use the backslash for continuation +(e.g. as B(1) does). Other differences: B doesn't support the full set of B options, and it uses Perl regular expressions rather than POSIX. @@ -338,15 +345,22 @@ B's exit status. =head1 LIMITATIONS Not all b options are supported. Options that aren't implemented -but might be someday include B<--color>, B<-a>, B<-A>, B<-B>, B<-C>. +but might be someday include B<--color>, B<-a>, B<-A>, B<-B>, B<-C>, B<-o>. I don't intend to implement every single option B has, there are too many of them. There are no long options other than B<--help> and B<--version>. +B does not comply with the POSIX (or any other) standard for +B, and does not intend do. + =head1 AUTHOR B was written by B. Watson and released under the WTFPL: Do WTF you want with this. +=head1 SEE ALSO + +B(1), B(1) + =cut -- cgit v1.2.3