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: John Cowan
Subject: Re: A suggestion to add to gnu ed: command line option to start on line foo or bar.
Date: Tue, 28 Feb 2023 23:33:17 -0500

Ah, okay; I see that now in section 9 of the info manual.  I hadn't noticed
it before.  So this is fine.

I have some other fairly small wish-list items for consideration as ed
features.  Where should I put them; on this mailing list, or elsewhere?

On Tue, Feb 28, 2023 at 6:26 PM Antonio Diaz Diaz <antonio@gnu.org> wrote:

> 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]