title: Bash script exiting prematurely when calling another script inside it
body: <p>I have a bash script which calls another bash script, like so:</p>
  
  <pre><code>#!/bin/bash
  echo "Hi"
  ./script-two.sh
  echo "Hello!"
  </code></pre>
  
  <p>The problem that I have is that it never makes it to printing "Hello!"</p>
  
  <p>I think this is because ./script-two.sh (Which I did not write) is somehow exiting or changing the shell. I have included this script at the end of this post.</p>
  
  <p>Is there a way I can gurentee that my execution will continue after script-two.sh executes?</p>
  
  <p>I have looked into using the trap command, but I don't fully understand its use properly.</p>
  
  <p>Thanks,</p>
  
  <p>Casey</p>
  
  <p>Here is the contents of what would be script-two.sh</p>
  
  <pre><code>    #!/bin/sh
  #  This file is part of the DITA Open Toolkit project hosted on 
  #  Sourceforge.net. See the accompanying license.txt file for 
  #  applicable licenses.
  #  (c) Copyright IBM Corp. 2006 All Rights Reserved.
  
  export DITA_HOME=cwd
  
  
  if  [ "${DITA_HOME:+1}" != "1" ]; then 
     echo "DITA_HOME environment variable is empty or not set";
     exit 127;
  fi
  
  echo $DITA_HOME
  
  cd "$DITA_HOME"
  
  # Get the absolute path of DITAOT's home directory
  DITA_DIR="`pwd`"
  
  echo $DITA_DIR
  
  if [ -f "$DITA_DIR"/tools/ant/bin/ant ] &amp;&amp; [ ! -x "$DITA_DIR"/tools/ant/bin/ant ]; then
  chmod +x "$DITA_DIR"/tools/ant/bin/ant
  fi
  
  export ANT_OPTS="-Xmx512m $ANT_OPTS"
  export ANT_OPTS="$ANT_OPTS -Djavax.xml.transform.TransformerFactory=net.sf.saxon.TransformerFactoryImpl"
  export ANT_HOME="$DITA_DIR"/tools/ant
  export PATH="$DITA_DIR"/tools/ant/bin:"$PATH"
  
  NEW_CLASSPATH="$DITA_DIR/lib:$DITA_DIR/lib/dost.jar:$DITA_DIR/lib/commons-codec-1.4.jar:$DITA_DIR/lib/resolver.jar:$DITA_DIR/lib/icu4j.jar"
  NEW_CLASSPATH="$DITA_DIR/lib/saxon/saxon9.jar:$DITA_DIR/lib/saxon/saxon9-dom.jar:$NEW_CLASSPATH"
  NEW_CLASSPATH="$DITA_DIR/lib/saxon/saxon9-dom4j.jar:$DITA_DIR/lib/saxon/saxon9-jdom.jar:$NEW_CLASSPATH"
  NEW_CLASSPATH="$DITA_DIR/lib/saxon/saxon9-s9api.jar:$DITA_DIR/lib/saxon/saxon9-sql.jar:$NEW_CLASSPATH"
  NEW_CLASSPATH="$DITA_DIR/lib/saxon/saxon9-xom.jar:$DITA_DIR/lib/saxon/saxon9-xpath.jar:$DITA_DIR/lib/saxon/saxon9-xqj.jar:$NEW_CLASSPATH"
  if test -n "$CLASSPATH"
  then
  export CLASSPATH="$NEW_CLASSPATH":"$CLASSPATH"
  else
  export CLASSPATH="$NEW_CLASSPATH"
  fi
  
  "$SHELL"
  </code></pre>