Mixing Python And Bash

Jeff Epler jepler at unpythonic.net
Mon Nov 8 20:42:41 EST 2004


The bash manpage says:
    set [--abefhkmnptuvxBCHP] [-o option] [arg ...]
[...]
              -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 an until or
                      while loop, part of 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.

So place "set -e" at the top of your script, and it will exit as soon as
the first "simple command" exits with a nonzero exit status.

Jeff
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20041108/cd159811/attachment.sig>


More information about the Python-list mailing list