Try this:

$ wget https://raw.githubusercontent.com/davidgiven/ack/default/h/em_table
$ wget
https://raw.githubusercontent.com/davidgiven/ack/default/modules/src/em_code/make.em.gen
$ sh make.em.gen em_table ; echo $?

Out of the box, the output (ignoring the actual script output) ends with:

?
2

(--verbose shows this is the warning, as expected.)

But changing the script so Q is the last command just produces:

1

So, no diagnostic, but still a non-zero exit status. This is GNU ed 1.14.2
from Debian.

Adding -l does produce an exit status of 0 --- but will this still cause
genuine failures if, for example, there's a syntax error in the script?


On Tue, 22 May 2018 at 17:48 Antonio Diaz Diaz <anto...@gnu.org> wrote:

> Hello David,
>
> David Given wrote:
> > Since about ed 1.11, the ACK fails to build because some of the ed
> scripts
> > won't run any more. Here is an example of one:
> >
> > #!/bin/sh
> > echo "/* this part is generated from $1 at: " `date` "*/"
> > ed -s $1<<'EOI'
> > 1,/^$/d
> > 1,/^$/d
>
> I can't find the problem without a sample of the file processed by this
> script. I suggest you to add a --verbose option to the invocation of ed
> above in order to get a diagnostic beyond the '?' shown by ed by default:
>
> ed -v -s $1 <<'EOI'
>
> After this change I get this result (using a random text file):
> $ ./make.em.gen.new tmp.txt ; echo $?
> /* this part is generated from tmp.txt at:  Tue May 22 17:35:13 CEST 2018
> */
> ?
> script, line 3: No match
> 1
>
>
> > Does anyone know what's happening here, and if there's a way to persuade
> ed
> > to quit with an exit status of 0? (I'd rather not discard ed's exit
> status
> > as that would hide processing errors in the scripts.)
>
> You may try adding -l to the invocation of ed:
> '-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.
>
_______________________________________________
bug-ed mailing list
bug-ed@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-ed

Reply via email to