bug-ed
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A suggestion to add to gnu ed: command line option to start on line


From: Antonio Diaz Diaz
Subject: Re: A suggestion to add to gnu ed: command line option to start on line foo or bar.
Date: Wed, 01 Mar 2023 00:27:27 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i586; en-US; rv:1.9.1.19) Gecko/20110420 SeaMonkey/2.0.14

John Cowan wrote:
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.

Per contra, the point of the proposed -e option is to force an immediate
exit on error.

Ooops! I forgot to test for interactive mode and made -l avoid the immediate exit on error also in scripted mode.

I have just uploaded ed-1.20-pre2 which in case of mismatch fails immediately with exit status 1 unless -l is specified and mode is interactive.

For example, suppose we want to edit a file using a script
that removes all except certain lines (using the 'v' command) and then
writes out the file.  But if there are no such lines, it is not the right
file.

This situation will cause ed to return an error message and code, but the
file (now empty) will still be written out, which is a Very Bad Thing.  The
proposed -e option will abort ed as soon as the search fails rather than
carrying on to the end of the script and only then returning an error.  The
same would be the case if the purpose of the script was to delete lines
100-200 and there were no such lines.

I see. When you said "-e ... causes termination with error status 1 when *any* error is detected" you meant "any error also in the script, not only in the new '+' option". But ed already exits immediately with non-zero status when any error is found and stdin is a regular file. Is this not enough?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]