linux - Unexpected behavior with "set -o errexit" on AIX -
this script shell works fine on gnu/linux not on aix 5.3
#!/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 expected output :
/bin/bash zzz aaa ccc
on aix, i've got 1 :
/bin/ksh zzz aaa
without "set -o nounset -o errexit" works fine... don't understant why. explain me wrong in script shell.
thanks,
rémy
edit 18 nov. : precision
set -e when option on, if simple command fails of reasons listed in consequences of shell errors or returns exit status value >0, , not part of compound list following while, until, or if keyword, , not part of , or or list, , not pipeline preceded ! reserved word, shell shall exit. http://explainshell.com/explain?cmd=set+-e
in example, second test "[ 1 -eq 0 ]" part of and, should see output "ccc". test returns 1, traps output "bbb", should'nt exit script.
rémy
have same behavior on aix 6 , 7
rémy
Comments
Post a Comment