when using -e in bash, exclamation mark before a passing command still doesn't cause the script to fail -
i thought following script print 'hello' , exit '1'
#!/bin/bash -e ! echo hello echo world
however, prints
hello world
and exits 0
the following script exits 1:
#!/bin/bash -e ! echo hello
and following
#!/bin/bash -e echo hello | grep world ! echo hello echo world
but reason -e option doesn't manage fail script when command returns failing exit code due ! half way through. can offer explanation make me feel better this?
http://www.gnu.org/software/bash/manual/bashref.html#the-set-builtin
the -e command fail script command returning non-zero code, except cases, while loops, or commands returning 0 inverted ! option. ! echo hello
return 1 (0 inverted !
) -e
option won't fail.
but if make exit status 42
, have script failed.
Comments
Post a Comment