set -e and set -x in shell script

set -x

Print shell command before execute it. This feature help programmers to track their shell script.

set -e

If the return code of one command is not 0 and the caller does not check it, the shell script will exit. This feature make shell script robust.

set -e and set -x often appear at the head of shell script:

set -x
set -e

echo "I am a shell script."

Or use as shell command:

sh -xe shell_script.sh

Reference: http://julio.meroh.net/2010/01/set-e-and-set-x.html

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)