On Sat, May 21, 2016 at 07:02:46PM +0100, Gavin Smith wrote:
> OK, so with this shell any "eval" statement can cause an exit under
> "set -e", regardless of the context of the statement?
> 
> Is this code wrong (in "run_tex")?
> 
>   verbose "$0: Running $tex_cmd ..."
>   if eval "$tex_cmd" >&5; then
>     case $out_lang in
>       dvi | pdf ) move_to_dest "$in_noext.$out_lang";;
>     esac
>   else
>     error 1 "$tex exited with bad status, quitting."
>   fi
> 
> If "$tex_cmd" fails, then an exit will be triggered, and the error
> message "exited with bad status" won't be given.

Yes, I think so. I tried with following program:

--8<-------------------------------------------------------------------
#! /bin/sh

set -e

if eval false; then
  echo "foo"
else
  echo "bar"
fi
--8<-------------------------------------------------------------------

and it generates no output at all (without "set -e" it prints "bar").

> Should parentheses around the "eval" be used here?

With

if (eval false); then

it prints "bar" irrelevant of "set -e".

So parentheses seem do work (but I do not know if there are other side
effects to care about as I am not a shell script expert).

Best regards,
Ingo

Reply via email to