Simon Geard wrote:

> 
> If the instructions aren't part of a script, what exactly does the "bash
> -e" step contribute? Start a new shell for running commands in, which
> should exit any time one of them fails? The -e might be useful in an
> shell script (i.e the #!/bin/bash case), but what's the point for an
> interactive shell?

Hmm, I see no indication in the man page that 'set -e' should be limited
to a non-interactive shell.

-e      Exit immediately if a *simple command* (see SHELL  GRAMMAR
        above) exits with a non-zero status.  The shell does not
        exit if the command that fails is part  of  the  command
        list  immediately  following  a  while or until keyword,
        part of the test in an if statement, part of a && or  ??
        list, or if the command's return value is being inverted
        via !.  A trap on ERR, if set, is  executed  before  the
        shell exits.

IMO a loop to handle repetitive tasks does not qualify as a 'script'.
Of course that is my opinion, but I guess if automating a task
constitutes a script, then we should review all the pipes and redirected
output in the book.  ;-)

Seriously though, this is a perfect example of -e's use in an
interactive shell.  I could have easily used three conditional breaks
and two conditional exits, but fortunately, ease of use was considered.
 Besides, it might have looked too much like a script if I had done it
that way! ;-)

-- DJ Lucas

-- 
http://linuxfromscratch.org/mailman/listinfo/blfs-support
FAQ: http://www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page

Reply via email to