From fd9d3fae5c74f9f06ccfcc139ca37954b3abc117 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Sun, 2 Feb 2025 16:47:20 -0500 Subject: bsgrep: cosmetics, docs. --- bsgrep | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'bsgrep') diff --git a/bsgrep b/bsgrep index 65d138c..bae517d 100755 --- a/bsgrep +++ b/bsgrep @@ -130,15 +130,13 @@ while(<>) { } } if(/$cont\s+$/) { - warn "$self: $ARGV, line $.: whitespace after continuation, malformed input?\n" unless $opt{s}; + warn "$self: $ARGV:$.: whitespace after continuation, malformed input?\n" unless $opt{s}; } s/^\s+// if $out && $opt{w}; $start_line = $. unless defined $out; $out .= $_; if(/$cont$/) { - if($opt{k}) { - $out .= "\n"; - } else { + if(!$opt{k}) { $out =~ s/$cont$//; } } else { @@ -149,7 +147,7 @@ while(<>) { # reset $. on each new file (perldoc -f eof) if(eof) { if($out) { - warn "$self: $ARGV: last line ends with continuation\n" unless $opt{s}; + warn "$self: $ARGV:$.: last line ends with continuation\n" unless $opt{s}; handle_line($out); undef $out; } @@ -189,6 +187,9 @@ options, and it uses Perl regular expressions rather than POSIX. Input is read from one or more files, or standard input if no files are given. Output goes to standard output. +The search is done after lines are joined together, so the regex can +match text split across continuation lines. + If B is run as B (via symbolic or hard link, or just copying the executable), it will simply join together continued lines without searching for anything. In this mode, only the B<-k>, B<-n>, @@ -206,12 +207,14 @@ Use I as the continuation character, rather than a backslash. =item -k -Keep the backslashes and newlines when joining continued lines together. +Keep the continuation characters when joining continued lines together. This option does not exist in B. =item -n -Prefix output lines with line numbers (same as B). +Prefix output lines with line numbers (same as B). For lines +that are split with continuation characters, the line number will be +that of the first line in the set. =item -w -- cgit v1.2.3