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: Mon, 27 Feb 2023 13:16:56 -0500

On Mon, Feb 27, 2023 at 10:04 AM Antonio Diaz Diaz <antonio@gnu.org> 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'.

> 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.  This is good when you are trying to do an automated edit (a
common use case), but you want it to fail if any assumptions made by the
script are false.


reply via email to

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