This script shell works fine on GNU/Linux but not on AIX 5.3 and later :
On GNU/Linux, I've got the expected output :
On AIX, I've got this one :
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.
man ksh :
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.
Thanks
Rémy
Code:
#!/bin/sh
echo $SHELL
set -o nounset -o errexit
[ 1 -eq 1 ] && {
echo "zzz"
} && echo "aaa" && [ 1 -eq 0 ] && echo "bbb"
echo "ccc"
On GNU/Linux, I've got the expected output :
/bin/bash
zzz
aaa
ccc
On AIX, I've got this one :
/bin/ksh
zzz
aaa
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.
man ksh :
-e
Executes the ERR trap, if set, and exits if a command has a nonzero exit status, unless in the following conditions:
* The simple command is contained in a "&&" or "||" list.
* The simple command immediately follows "if", "while" or "until".
* The simple command is contained in a pipeline following "!".
This mode is disabled when profiles are read.
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.
Thanks
Rémy