title: "source" in ruby subshells
body: <p>I need to run a shell command from a ruby application. I'm using <code>system()</code> but this also applies to backticks.</p>
  
  <p>When running my command, I need to load a shell script first that sets up some things so I try something like this:</p>
  
  <pre><code>system("source my_script.sh &amp;&amp; my_command")
  </code></pre>
  
  <p>On my Mac laptop this works as intended but on my ubuntu server I get:</p>
  
  <pre><code>sh: 1: source: not found
  </code></pre>
  
  <p>I was wondering about the "sh" in there since my shell should be a bash, so tried this:</p>
  
  <pre><code>system("echo $SHELL &amp;&amp; source my_script.sh &amp;&amp; my_command")
  </code></pre>
  
  <p>Which gives me:</p>
  
  <pre><code>/bin/bash
  sh: 1: source: not found
  </code></pre>
  
  <p>So, it is using the right shell but for some reason, <code>source</code> does not work.</p>
  
  <p>Why? And what can I do about it?</p>
  
  <p><strong>Update</strong>
  As Sergio Tulentsev pointed out, Ruby does not necessarily use the shell that is set in $SHELL.</p>
  
  <p>This gave me the actual shell that ruby was using:</p>
  
  <pre><code>system("ps -p $$ | tail -1 | awk '{print $NF}'")
  sh
   =&gt; true
  </code></pre>
  
  <p>So, it's using sh. Can I somehow force it to use bash?</p>