On Mon, Jun 19, 2017 at 03:57:35AM -0600, Anthony J. Bentley wrote: > Hi, > > Jason McIntyre writes: > > ok by me. note that posix ex(1) does detail a working [s]ubstitute command, > > so i'm not sure whether we should support this or not. > > Hm, so it does. I think I would prefer to follow POSIX in this case. > Here's a diff to allow "substitute" to work. > > Annoyingly, there's an ambiguity in the POSIX synopsis (and ours). > > [2addr] s[ubstitute][/pattern/repl/[options][count][flags]] > > This implies that "su" could expand to "substitute". But it expands (and > should expand) to "suspend" instead. Since in our vi the first match > always wins, the simplest way to implement this is to use separate ex > commands: > > [2addr] s[/pattern/repl/[options][count][flags]] > [2addr] sub[stitute][/pattern/repl/[options][count][flags]] > > There are already plenty of duplicate commands (e.g., "#"/"nu", > "cd"/"chd", "co"/"t"...) so I think it's an acceptable approach.
This looks like a reasonable approach and it appears to work. When I looked at this after jmc's question, I was scared off by the comment > * Adding new commands starting with 's' may break the substitute command > code > * in ex_cmd() (the ex parser). Read through the comments there, first. which is also visible in your diff. I'm not entirely sure what this is talking about. Thus, only a hesitant ok for the C-part of your patch. I'll leave it to jmc to verify the vi.1 part in full detail, but it does look good to me. Thanks!