From 7948fdd3e5add75d64465a1f48527eeb98a1d152 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Wed, 5 Feb 2025 03:58:27 -0500 Subject: bsgrep: fix -s exit status, implement -q. --- bsgrep | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'bsgrep') diff --git a/bsgrep b/bsgrep index 211a6f9..6dd5c43 100755 --- a/bsgrep +++ b/bsgrep @@ -22,7 +22,7 @@ $SIG{__WARN__} = sub { # from the 'while(<>)' or File::Find. if($m !~ /^$self:/) { $m = "$self: $m"; - $ret = 2 unless $opt{s}; + $ret = 2 unless $opt{q}; } print STDERR $m unless $opt{s}; @@ -315,22 +315,29 @@ select lines that match all of the patterns; the default is to select lines that match any of the patterns. This option doesn't exist in B. +=item -q + +Quiet: don't write to standard output. Exit status will be zero if +a match was found, even if there were errors. This doesn't prevent +warnings/errors being printed to standard error; use B<-s> to silence +those. Same as B. + =item -r Recursively read all files under each directory, following symlinks only if they're on the command line. If no files or directories are given, reads the current directory. Same as B. -=item -v - -Print only lines that do I match (same as B). - =item -s Silence warnings (same as B). This includes error messages about unreadable files as well as warnings about the input (see B, below). +=item -v + +Print only lines that do I match (same as B). + =back =head1 EXAMPLE @@ -409,7 +416,7 @@ to be Unicode, it will be assumed ISO-8859-1, and converted to Unicode. =head1 EXIT STATUS 0 if there were any matches, 1 if there were none, or 2 if there -were errors (e.g. nonexistent file). However, with B<-s>, the exit +were errors (e.g. nonexistent file). However, with B<-q>, the exit status will be 0 or 1 even if there were errors. This is the same as B's exit status. -- cgit v1.2.3