I have tested your scripts and everything works just as it should. Check your system for anything special you might have done.
work:~$ ./script1 This is ./script1 The value of $- is 'hB' This is ./script2 The value of $- is 'hB' If the grep fails, this will never echo. work:~$ cat script1 #!/bin/sh echo This is $0 echo The value of \$- is \'$-\' set -e ./script2 work:~$ cat script2 #!/bin/sh echo This is $0 echo The value of \$- is \'$-\' grep 'non-existing-text' /usr/man/man1/bash* echo If the grep fails, this will never echo. --- +++ --- +++ --- +++ --- +++ --- +++ --- +++ --- +++ ---