I use set -e to stop bash script on first error.
All work OK unless I use command with &&:
$ cat script
set -e
cd not_existing_dir && echo 123
echo "I'm running! =P"
$
$ ./script
./script: line 2: cd: not_existing_dir: No such file or directory
I'm running! =P
$
compared with:
$ cat script
set -e
cd not_existing_dir
echo "I'm running! =P"
$
$ ./script
./script: line 2: cd: not_existing_dir: No such file or directory
$
The first example still echoes I'm running!, but the second one doesn't. Why do they behave differently?
UPD. Similar question: https://stackoverflow.com/questions/6930295/set-e-and-short-tests
cdcommandset -ebehavior is surprising.set -eu -o pipefailspecificallypipefail.