I am running Intergraph's CLIX 3.1 r.6.5.7 ( an AT&T system V release 3
derivative I believe) on an Intergraph workstation.
I am having unexpected behaviour with a ksh script as follows:
#
# This is a simple subshell command group which invokes the errexit function
#
(
set -e
trap "echo exit trap; exit 1" ERR
(exit 1)
echo $?
exit 0
)
#
# The following test should be equivalent to a '||' OR list
#
if [[ $? != 0 ]]
then
echo failed
fi
#
# In the following case, '||' OR list is used. I expected the result
# to be the same as the sequence above, but it isn't. For some reason,
# on my system the OR list interferes with the 'errexit' (-e) function,
# and the trap is never executed.
#
(
set -e
trap "echo exit trap; exit 1" ERR
(exit 1)
echo $?
exit 0
) || echo failed
Intergraph says this works as designed. Their explanation is that the
set -e option failes in the latter case because the subshell command
grouping is a component of a larget compound command (the OR list).
I though the subshell command grouping '(compound-list)' was
functionally equivalent to running compound-list in a subshell, except
that the process number doesn't change, in which case whether it was
part of a larger compound command would be irrelevant.
Can anyone try this on other implementations and let me know what the
results are?
Is Intergraph wrong and this a bug, or have I misunderstood something?
Thanks for any help.
Ian Goodacre