title: sh: 2: ./ci.sh: Syntax error: word unexpected
body: <p><code>ci.sh</code>:</p>
  
  <pre><code>#!/bin/bash
  { ERROR=$(npx cypress run configFile=reporter.config.json 2&gt;&amp;1 1&gt;&amp;$out); } {out}&gt;&amp;1
  if [[ $ERROR == *"name_to_handle_at"* ]]; then # ERROR has the cypress error
      echo "expected ERROR detected: $ERROR"
      return 0
  elif [ ! -z "$ERROR" ]; then # ERROR is not empty
      echo "ERROR detected: $ERROR"
      exit 1
  fi
  echo "no errors detected"
  return 0 # row 11
  </code></pre>
  
  <p>Trying to start it with a <code>npm</code> script:</p>
  
  <pre><code>    "test": ". ./ci.sh &amp;&amp; echo \"finished\"",
  </code></pre>
  
  <p><code>npm run test</code> results in the error:</p>
  
  <pre><code>sh: 2: ./ci.sh: Syntax error: word unexpected
  </code></pre>
  
  <p>Don't really know what I'm doing wrong. I want the program to exit and not display "finished" if an error is detected from the command in the script file but I want it to continue if it finds a specific error or doesn't find any at all. When I use exit 0 in the script it never reaches "finished" (which makes sense since it's exiting the shell).</p>
  
  <p>Bash is my main shell. NPM uses however <code>sh</code>.</p>