title: How can I use aliases defined in bash profile in a backtick operation with ruby?
body: <p>After a long time googling and SOing…</p>
  
  <p>I've got some aliases defined in my <code>.bash_profile</code> file. For instance:</p>
  
  <pre><code>alias say_hello="echo 'Hello!'"
  </code></pre>
  
  <p>I want to use them in a backtick operation in ruby, sourcing my bash profile. But I fail.</p>
  
  <p>I tried:</p>
  
  <pre><code># (ruby code)
  res = `. /Users/thatsme/.bash_profile;say_hello`
  # =&gt; sh: say_hello: command not found
  </code></pre>
  
  <p>Or even:</p>
  
  <pre><code>res = `. /Users/thatsme/.bash_profile;shopt -s expand_aliases;say_hello`
  # =&gt; sh: say_hello: command not found
  </code></pre>
  
  <p>(note: I don't want to hard-code the alias in the backtick operation).</p>
  
  <h2>Note</h2>
  
  <p>The bash profile is well sourced. If I put <code>echo "I'm sourced"</code> in it, my backtick operation echoes the text.</p>
  
  <pre><code>res = `. /Users/thatsme/.bash_profile;say_hello`
  # =&gt; 
      sh: say_hello: command not found
      I'm sourced
  </code></pre>
  
  <p>Thanks for help.</p>