John Cowan wrote:
In addition I have also implemented
+?pattern to set the current line to the *last* line matching the pattern.
Good feature; it is also present in 'ex'.
I took the idea from GNU nano. I have never used 'ex' and all the
information I have about 'ex' comes from its POSIX page, which does not seem
to mention +n, +/pattern, or +?pattern.
But I would like to know what do you think it should be the behavior when
there is no match for 'pattern'. I have made ed to immediately exit with
error status 1, but I can change that behavior if something better (and
not misleading) is suggested.
I think you should in that case print "?" and go on, as it is mostly just a
convenience, and the intention to edit the file is clear. This is
equivalent to what 'ex' does.
However, this behavior is not so good in a script. I think therefore you
should add a command-line option -e (long form: --errexit), like the shell
option, which causes termination with error status 1 when *any* error is
detected.
I agree that ed should perhaps behave differently in the interactive and
scripted cases, but I think we can use the existing option '-l,
--loose-exit-status' to ignore a mismatch in the interactive case instead of
using a new option to force an error in the scripted case.
I have just uploaded ed-1.20-pre1 with these changes implemented. Please
test it and tell me what do you think.
http://download-mirror.savannah.gnu.org/releases/ed/ed-1.20-pre1.tar.lz
Best regards,
Antonio.