Why does ((0)) cause a Bash script to exit if `set -e` directive is present?
问题 This outputs before\n : #!/usr/bin/env bash set -e echo before ((0)) echo after Removing set -e or changing ((0)) to ((1)) makes the program output before\nafter\n as expected. Why does ((0)) trigger the set -e exit condition? 回答1: This will explain: ((0)) echo $? 1 ((1)) echo $? 0 So it is due to non-zero return status of arithmetic expression evaluation in (( and )) your script is exiting when set -e is being used. As help set says this: -e Exit immediately if a command exits with a non