title: Sourcing variables as local in bash
body: <p>I've got a bash file where are defined a number of variables:</p>
  
  <pre><code>VAR1="value1"
  VAR2="value2"
  # ...
  </code></pre>
  
  <p>I need to <em>import</em> these variables in <code>~/.bashrc</code> in order to customize <code>PS1</code>, <code>PATH</code> and so on, but don't want that the imported variables can be accessed outside of <code>~/.bashrc</code>.</p>
  
  <p>To make myself clear with an example, I'd like to do something like this:</p>
  
  <pre><code>function setPATH
  {
      local . ~/bashvars.sh # this isn't legal, of course...
      PATH="$PATH:$VAR1"    # $VAR1 is defined in ~/bashvars.sh
      unset -f setPATH
  }
  setPATH
  </code></pre>
  
  <p>How can I do this?</p>