Unexpected behavior with "set -o errexit" on AIX <p>This script shell works fine on GNU/Linux but not on AIX 5.3</p> <pre><code>#!/bin/sh echo $SHELL set -o nounset -o errexit [ 1 -eq 1 ] &amp;&amp; { echo "zzz" } &amp;&amp; echo "aaa" &amp;&amp; [ 1 -eq 0 ] &amp;&amp; echo "bbb" echo "ccc" </code></pre> <p>On GNU/Linux, I've got the expected output :</p> <pre><code>/bin/bash zzz aaa ccc </code></pre> <p>On AIX, I've got this one : </p> <pre><code>/bin/ksh zzz aaa </code></pre> <p>Without "set -o nounset -o errexit" it works fine... I don't understant why. Could you explain me what is wrong in my script shell.</p> <p>Thanks, </p> <p>Rémy</p> <hr> <p>Edit 18 nov. : Precision</p> <blockquote> <p>set -e When this option is on, if a simple command fails for any of the reasons listed in Consequences of Shell Errors or returns an exit status value >0, and is not part of the compound list following a while, until, or if keyword, and is not a part of an AND or OR list, and is not a pipeline preceded by the ! reserved word, then the shell shall immediately exit. <a href="http://explainshell.com/explain?cmd=set+-e" rel="nofollow noreferrer">http://explainshell.com/explain?cmd=set+-e</a></p> </blockquote> <p>In my example, the second test "[ 1 -eq 0 ]" is part of an AND, so I should see the output "ccc". This test returns 1, it traps the output "bbb", but should'nt exit the script.</p> <p>Rémy</p>