title: Can a function be extended in Bash?
body: <p>If I define a function in a file, say <strong>test1.sh</strong>:</p>
  
  <pre><code>#!/bin/bash
  
  foo() {
      echo "foo"
  }
  </code></pre>
  
  <p>And in a second, <strong>test2.sh</strong>, I try to redefine <code>foo</code>:</p>
  
  <pre><code>#!/bin/bash
  
  source /path/to/test1.sh    
  ...
  foo() {
      ...
      echo "bar"
  }
  foo
  </code></pre>
  
  <p>Is there a way to change <strong>test2.sh</strong> to produce:</p>
  
  <pre><code>foo
  bar
  </code></pre>
  
  <p>I know it is possible to do with Bash built-ins using <code>command</code>, but I want to know if it is possible to extend a user function?</p>