I have this bash script:
echo "x" & X=$!
echo "y" & Y=$!
( echo "z" ; exit 0; ) & Z=$! # this line
wait ${X} && echo "X $?"
wait ${Y} && echo "Y $?"
wait ${Z} && echo "Z $?"
when I change exit 0 to exit 1, the last echo statement of the script does not execute. For example, here is the output when the exit code is 0:
x
X 0
z
y
Y 0
Z 0
but when I change it to 1:
x
y
X 0
z
Y 0
I am assuming what's in the parentheses should be executed in a subshell. Anyone know why my code does this?