title: How to import custom bash functions to be used in PHP exec/system/etc?
body: <p>I'm writing a command-line application that will substitute a bunch of bash functions and manual work made by a team of developers. Currently, half of what we usually do is inside a <code>~/.functions</code> file that is sourced in the <code>~/.bash_profile</code> of each developer.</p>
  
  <p>My command-line application is written in PHP, and for a while I would need to run some of those functions from inside my application. However, the following code would not work, the output says it cannot find the given function:</p>
  
  <pre class="lang-php prettyprint-override"><code>exec('bash my_legacy_functions.sh');
  exec('my_custom_legacy_function param1 param2');
  </code></pre>
  
  <p>I may be wrong, but I could understand that every <code>exec()</code> call runs a command in a separate process, meaning the functions would not be available for subsequents <code>exec()</code> calls. Is this right, and if yes, would it be possible to override this behaviour without having to bundle everything into one call?</p>