On Sun, Jul 07, 2019 at 10:12:13PM +0300, cho...@jtan.com wrote:
> ropers writes:
> > > matthew: "ed reacts differently depending whether or not it's included".
> > > can you explain how?
> 
> If I recall correctly, if the trailing delimiter is _not_ included then ed 
> prints the result of the substitution. Possibly only if interactive.
> 
> > W/r/t Matthew's concerns, I also note that the
> > > (.,.)s/re/replacement/
> > section does mention this in its second paragraph:
> > >> If one or two of the last delimiters is omitted, then the last line
> > >> affected is printed as though the print suffix p were specified.
> > I'm not quite sure what is meant by omission of *two* of the last
> > delimiters there, but this does at least seem relevant to what we're
> > discussing here.
> 
> Yes that sounds about right. Looks like some part of this behaviour is in 
> documented already.
> 
> The pedantic part of me likes getting this pointless thing right but the 
> pedantic part of me also wants to make sure it's actually right before 
> changing something that evidently works already and isn't bothering anybody. 
> I managed to learn ed with the manpage as it is.
> 
> It sounds like there might be a bit of confusion wrt. what does/doesn't 
> happen vs. what's documented. Can the various interactions under discussion 
> be actually clarified and enumerated to be sure we're not changing a minor 
> mistake for a new mistake? I can do this tomorrow if nobody else jumps in but 
> I'd get it wrong if I tried it now.
> 
> Matthew
> 

this is getting silly - we're mixing talking about how /re/ and ?re?
work as addresses and as regular expressions in other places. dropping
the trailing [/?] does not apply to regular expressions everywhere.

even if i have this wrong (to be fair, not that unlikely), we should
just concentrate on one thing at a time.

regarding how dropping two delimiters works in an 's' command, although
i'm not sure really of the reason, you can do:

        1,$s/re

which effectively drops /replacement/

so here's my diff. i think we should keep it short.  if there are
other cases where things can dropped, i'd rather look at them
separately.

the question for me is: posix mandates this in address ranges. our
ed behaves this way. is there a reason not to document this?

jmc

Index: ed.1
===================================================================
RCS file: /cvs/src/bin/ed/ed.1,v
retrieving revision 1.70
diff -u -r1.70 ed.1
--- ed.1        26 Apr 2018 12:18:54 -0000      1.70
+++ ed.1        7 Jul 2019 19:56:11 -0000
@@ -267,6 +267,7 @@
 .Ar re .
 The search wraps to the beginning of the buffer and continues down to the
 current line, if necessary.
+The second slash can be omitted if it ends a line.
 .Qq //
 repeats the last search.
 .It Pf ? Ar re ?
@@ -274,6 +275,7 @@
 .Ar re .
 The search wraps to the end of the buffer and continues up to the
 current line, if necessary.
+The second question mark can be omitted if it ends a line.
 .Qq ??
 repeats the last search.
 .It \&' Ns Ar lc

Reply via email to