I have a script that calls another script. When the child script fails, I'd like the parent to fail as well.In the child script child_1.sh, I have something like this:if [ $SOME_BAD_CONDITION ] ; then  echo Error message....  exit 1fiIn the parent, I have this:#!/bin/bashset -e#...bash ./child_1.shecho continuing to next step...bash ./child_2.shbash ./child_3.sh#...I've set up my environment so that $SOME_BAD_CONDITION will always happen, and the script exits as expected and the error message does print, but the parent script continues: the message continuing... is printed and the next script begins executing.I thought that having set -e would ensure that my parent script fails if any child script exists with a non-zero exit code, but that doesn't seem to be happening. I'm not sure what I got wrong here...bash version: 4.2.25UPDATE:I tried echoing $?: bash ./child_1.shecho $?echo continuing to next step...The output looks like this:Error message....0continuing to next step...Why doesn't the exit code from the child make it into the parent?ANSWER: The original code snippet was incomplete. The exit 1 was inside a code block that was piped to tee. My attempt to post a clean, short code sample ignored this because I did not realize how significant it was (I'm still fairly new to bash scripting). See my posted answer for details.
Parent script continues when child exits with non-zero exit code
bash;shell script;pipe;exit
So, I might have made an error in not posting enough details about the child script - I simplified it for the purpose of this question, but maybe too much. The exit statement was buried inside a code block (between { and }) which was piped to tee for logging:{  #...  if [ $SOME_BAD_CONDITION ] ; then    exit 1  fi  #...} | tee -a $LOGFILEecho script ended at $date>>$LOGFILEFrom what I understand, I always got a return code of 0 from this child script because the last echo was returning 0. I did some research and discovered $PIPESTATUS. I was able to use this to ensure that when my script tried to exit with exit code 1, it would be passed up to parent script:{  #...} | tee -a $LOGFILEEXIT_CODE=${PIPESTATUS[0]}echo script ended at $date>>$LOGFILEexit $EXIT_CODECombined with John's suggestion, I have a solution that seems to be working.