diff options
-rwxr-xr-x | bsgrep | 17 |
1 files changed, 10 insertions, 7 deletions
@@ -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<bsgrep> is run as B<bsjoin> (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<char> 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<grep>. =item -n -Prefix output lines with line numbers (same as B<grep>). +Prefix output lines with line numbers (same as B<grep>). For lines +that are split with continuation characters, the line number will be +that of the first line in the set. =item -w |