Eric Blake wrote:
Among the ideas on the table (and likely to be discussed in today's
Austin Group meeting), is comparing the behavior of ed, vi, and ex, to
see if there is any common behavior among the various editors about
distinguishing between an interactive session (where it is very common
for the user to attempt all sorts of things that may create errors,
but because the session is interactive, they can then try other things
that clear the error - so it is okay for the overall exit status to be
0 despite intermediate errors) and a batch session (the editor is
invoked to run a specific script with no chance to modify that script
based on interactive reactions, so an exit status conveying whether
the script executed as expected makes sense).
Since 2006[1] GNU ed provides the option '-l, --loose-exit-status'[2] to
prevent some errors from affecting the exit status of an interactive
session. (It was suggested by Karl Berry IIRC):
-l
--loose-exit-status
Don't exit with bad status if a command happens to "fail" (for example if a
substitution command finds nothing to replace). This can be useful when ed
is invoked as the editor for crontab.
[1] https://lists.gnu.org/archive/html/bug-ed/2006-10/msg00020.html
[2] http://www.gnu.org/software/ed/manual/ed_manual.html#Invoking-ed
I don't know if '-l' (or a similar option) is preferable to detecting an
interactive session for the exclusion of some errors from the exit status. I
tend to prefer explicit options over automatic algorithms, but I'm open to
implement anything that is deemed adequate.
Best regards,
Antonio.