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: Andrew L. Moore
Subject: Re: A suggestion to add to gnu ed: command line option to start on line foo or bar.
Date: Tue, 11 Apr 2023 17:48:15 -0700
User-agent: Mozilla/5.0 (X11; Linux aarch64; rv:102.0) Gecko/20100101 Thunderbird/102.9.1

On 2023-02-27 13:16:56 -0500 John Cowan wrote:
┃ 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.

Traditionally, reading scripts from piped input suppressed
exit-on-error behavior. For instance, the following script fails
prematurely:

ed -vs <<EOF
a
hello
.
s/x
a
world
.
wq o.tmp
EOF

and no file 'o.tmp' is created.  But by piping it:

cat <<EOF | ed -vs
a
hello
.
s/x
a
world
.
wq o.tmp
EOF

the script completes and the file 'o.tmp' is created with contents
'hello\nworld\n'. The failed substitution is still reported, but the
exit-on-error behavior is suppressed.

This has been supported by ed for nearly 50 years. Adding a new flag
doesn't provide any new functionality, but it does break portability.

Having said that, if Antonio chooses to add an explicit flag, please
let it be something other than `-e', which is already used by sed to
introduce a script on the command line.  I use this flag in the same
manner in my implementation of ed and hope that it might eventually be
adopted by GNU ed (see:https://github.com/slewsys/ed#script-flags).
-AM



reply via email to

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