diff options
author | B. Watson <urchlay@slackware.uk> | 2025-02-02 16:00:34 -0500 |
---|---|---|
committer | B. Watson <urchlay@slackware.uk> | 2025-02-02 16:00:34 -0500 |
commit | 29c35ba17c7a73fe495dc87d2d16e6fef2231065 (patch) | |
tree | 1441877edd55448f8b8155ea1404438808d900c2 | |
parent | 4608f3975eade7b9b516b8b6658cd08bf0b2c5cc (diff) | |
download | misc-scripts-29c35ba17c7a73fe495dc87d2d16e6fef2231065.tar.gz |
bsgrep: fix double newlines from File::Find warnings; commentary; docs.
-rwxr-xr-x | bsgrep | 26 |
1 files changed, 20 insertions, 6 deletions
@@ -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<file> I<...>] =head1 DESCRIPTION -B<bsgrep> searches uses a regular expression to search for strings -in a file, much like B<grep>(1). The difference is, B<bsgrep> joins -together lines that use the backslash for continuation (e.g. as -B<sh>(1) does). +B<bsgrep> (backslash grep) uses a regular expression to search for +strings in a file, much like B<grep>(1). The main difference is, +B<bsgrep> joins together lines that use the backslash for continuation +(e.g. as B<sh>(1) does). Other differences: B<bsgrep> doesn't support the full set of B<grep> options, and it uses Perl regular expressions rather than POSIX. @@ -338,15 +345,22 @@ B<grep>'s exit status. =head1 LIMITATIONS Not all b<grep> 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<grep> has, there are too many of them. There are no long options other than B<--help> and B<--version>. +B<bsgrep> does not comply with the POSIX (or any other) standard for +B<grep>, and does not intend do. + =head1 AUTHOR B<bsgrep> was written by B. Watson <urchlay@slackware.uk> and released under the WTFPL: Do WTF you want with this. +=head1 SEE ALSO + +B<grep>(1), B<perl>(1) + =cut |