On 07/07/2019, ropers <rop...@gmail.com> wrote: > Second thought, maybe the 'i.e.'s should be changed to 'e.g.'s, > because '/' and '?' also work (instead of '//' and '??', > respectively), so '/re' and '?re' are indeed only examples. > > Or maybe this is overdoing it. I don't know. Whatever you all think is > best and most correct. I have no strong personal opinion on this. I'm > just trying to respond to mazocomp's reasonable observation and > suggestion.
Okay, so here's an "e.g." version of the patch, which also removes an extraneous `Ns` that was still present in the earlier, "i.e." version: 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 13:19:34 -0000 @@ -269,6 +269,9 @@ current line, if necessary. .Qq // repeats the last search. +The second slash is optional for a bare search without any suffixed command, e.g.\& +.Qq / Ns Ar re +is sufficient when followed by a newline. .It Pf ? Ar re ? The previous line containing the regular expression .Ar re . @@ -276,6 +279,9 @@ current line, if necessary. .Qq ?? repeats the last search. +The second question mark is optional for a bare search without any suffixed command, e.g.\& +.Qq ? Ns Ar re +is sufficient when followed by a newline. .It \&' Ns Ar lc The line previously marked by a .Ic k However: *This isn't even my final form*, because it does not take into account Matthew's concerns, which he hasn't clarified yet, perhaps because he's not subscribed to tech@: Thus Spake Chohag-jtan: >> Better to be thorough, if this is to be done. The final slash in a >> substitution is also unnecessary and ed reacts differently depending >> whether or not it's included. I expect it's the same for the other >> commands with delimited options. >> >> Matthew Quoth the Jason: > let's keep this on one mailing list only. since there's a diff, i guess > tech is now fine. > > matthew: "ed reacts differently depending whether or not it's included". > can you explain how? > > jmc Also, it says in the DESCRIPTION in `man 1 ed` that >> (...) commands have the structure: >> [address [,address]]command[parameters] and I guess since /re[/] and ?re[?] are technically addresses, that means that, with bare single addresses being legal and sufficient for search, the command is technically optional too. So would one write that as follows? >> [address [,address]][command[parameters]] Or would it make more sense to add a second, bare address form there? 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. Oh, and Jason, earlier on you recommended NOT to document the second delimiter omission with `g/RE`. Is there a reason why? I appreciate that on its own, `g/RE` may not seem to make too much sense at first sight, but it's actually different from `/RE`, and these are all legal: $ alias ed alias ed='ed -p ed:\ ' $ ed ed.1 20317 ed: H ed: /tuple .Ar n Ns -tuple ed: g/tuple .Ar n Ns -tuple .Ar n Ns -tuple . ed: 200,210g/tuple .Ar n Ns -tuple .Ar n Ns -tuple . ed: 200,205g/tuple .Ar n Ns -tuple ed: g/tuple/n 203 .Ar n Ns -tuple 208 .Ar n Ns -tuple . ed: q $ I've included the /n command form for clarification there. This is my edited ed.1. YMMV w/r/t line numbers. My ed has an `ed: ` prompt because I've aliased ed(1) to that. I would *maybe* even weakly suggest this diff: Index: dot.profile =================================================================== RCS file: /cvs/src/etc/skel/dot.profile,v retrieving revision 1.5 diff -u -r1.5 dot.profile --- dot.profile 2 Feb 2018 02:29:54 -0000 1.5 +++ dot.profile 7 Jul 2019 16:17:19 -0000 @@ -4,3 +4,5 @@ PATH=$HOME/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin:/usr/games export PATH HOME TERM + +if (-x /bin/ed) alias ed='ed -p ed:\ ' (NB: Perhaps `alias ed='ed -p ed\>\ '` or `alias ed='ed -p ed\*\ ' would be more acceptable?) This would be a confusion-decreasing convenience for new users, but maybe this is imposing too much of a personal viewpoint; you tell me; I have no strong opinion on this. I do however have a strong opinion on the next thing I've just found: The following diff incorporates three additional changes that fix a documentation bug that could result in actual data loss, or at least that's where it could lead an unwary user: 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 17:34:40 -0000 @@ -269,6 +269,9 @@ current line, if necessary. .Qq // repeats the last search. +The second slash is optional for a bare search without any suffixed command, e.g.\& +.Qq / Ns Ar re +is sufficient when followed by a newline. .It Pf ? Ar re ? The previous line containing the regular expression .Ar re . @@ -276,6 +279,9 @@ current line, if necessary. .Qq ?? repeats the last search. +The second question mark is optional for a bare search without any suffixed command, e.g.\& +.Qq ? Ns Ar re +is sufficient when followed by a newline. .It \&' Ns Ar lc The line previously marked by a .Ic k @@ -334,6 +340,9 @@ is not specified, then the default filename is used. Any lines in the buffer are deleted before the new file is read. The current address is set to the last line read. +Repeating this command immediately after an error indicating unwritten changes will edit +.Ar file +unconditionally. .It Ic e No \&! Ns Ar command Edits the standard output of .No \&! Ns Ar command , @@ -345,6 +354,7 @@ .Ar command is read. The current address is set to the last line read. +Repeating this command immediately after an error indicating unwritten changes will perform the action unconditionally. .It Ic E Ar file Edits .Ar file @@ -466,6 +476,9 @@ .It Ic q Quits .Nm ed . +Repeating this command immediately after an error indicating unwritten changes will quit +.Nm ed +unconditionally. .It Ic Q Quits .Nm This still omits the `g/RE` documentation that didn't suit Jason, it doesn't address the above DESCRIPTION thing, and again, this doesn't yet address Matthew's concerns. Cheers, Ian