title: exit form shell script not working as expected
body: <p>I have a function that is called twice with 2 different parameters. The function performs some checks and exits execution if check fails. If check succeeds, the execution continues. However in my case the execution is not exited, and it continues to call the function a second time.</p>
  
  <p>I am calling the function each time and storing the returned value in variables. From what I have understood looking through answers on google and stackoverflow, the problem seems to be the fact that when I am calling the function to store it in the variable, it is running in a subshell and the "exit" just exits execution from the subshell, while the shell script continues executing. I am providing the code below:</p>
  
  <pre><code>check_profile_path() {
      local profileToCheck=$1
      if [ -e "$pdfToolBoxPath/used_profiles/Check$profileToCheck.kfpx" ]; then
          return 0
      else
          outputArr[status]="failed"
          outputArr[message]="profile configuration path for $profileToCheck not found at specified path"
          exitCode=1
  
          end_execution
      fi
  }
  
  check_profile() {
      local profileName=$1
      check_profile_path $profileName
  
      local containedText=$($someApplicationPath $somePath/used_profiles/Check$profileName.kfpx $fileToCheck)
  
      echo "&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt; $profileName &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;"
      echo "$containedText"
      echo ""
  }
  
  end_execution() {
      jsonResult=$(create_json)
  
      echo $jsonResult
      exit $exitCode
  }
  
  colorSpaceProfileName="ColorSpace"
  resolutionProfileName="Resolution"
  
  colorSpaceCheckResult=$(check_profile $colorSpaceProfileName)
  echo "$colorSpaceCheckResult"
  resolutionCheckResult=$(check_profile $resolutionProfileName)
  echo "$resolutionCheckResult"
  </code></pre>
  
  <p>The output I recieve from this is:</p>
  
  <pre><code>{"status":"failed","message":"profile configuration path for ColorSpace not found at specified path"}
  &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt; Resolution &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;
  ProcessID   8..........
  </code></pre>
  
  <p>while I expect it to be just:</p>
  
  <pre><code>{"status":"failed","message":"profile configuration path for ColorSpace not found at specified path"}
  </code></pre>
  
  <p>I cannot set the proper syntax.. Please suggest..</p>