title: Execute multiple shell scripts concurrently
body: <p>I want to do the following things:<br><br></p>
  <ul>
  <li><p>Execute multiple shell scripts (here 2 scripts) concurrently.</p>
  </li>
  <li><p>Wait until both scripts finish</p>
  </li>
  <li><p>Dump return value of each script</p>
  </li>
  </ul>
  <p>However, <code>main.sh</code> does not work as expected.</p>
  <br>
  <h2>main.sh</h2>
  <pre><code>#!/bin/bash
  
  ret1=`./a.sh` &amp;
  ret2=`./b.sh`
  
  if [ &quot;${ret1}&quot;=&quot;&quot; -a &quot;${ret2}&quot;=&quot;&quot; ]; then
     sleep 1
  else
     echo ${ret1},${ret2}
  end
  </code></pre>
  <h2>a.sh</h2>
  <pre><code>#!/bin/bash
  sleep 10
  echo 1
  </code></pre>
  <h2>b.sh</h2>
  <pre><code>#!/bin/bash
  sleep 5
  echo 2
  </code></pre>