title: Bash array export?
body: <p>Is it possible to declare and export a <a href="/questions/tagged/bash" class="post-tag" title="show questions tagged 'bash'" rel="tag">bash</a> array from a single statement within a <strong>function</strong>?</p>
  
  <p>My current workaround is to first declare, then to export.</p>
  
  <pre><code>f() { foo=(1 2 3); export foo; }; f; export -p | grep foo=
  declare -ax foo='([0]="1" [1]="2" [2]="3")'
  </code></pre>
  
  <p>I observe that:</p>
  
  <pre><code>f() { export bar=(1 2 3); }; f; export -p | grep bar=
  &lt;no output&gt;
  </code></pre>
  
  <p>and:</p>
  
  <pre><code>f() { export baz="(1 2 3)"; }; f; export -p | grep baz=
  declare -x baz="(1 2 3)" # not an array
  </code></pre>
  
  <p>I use <a href="/questions/tagged/bash" class="post-tag" title="show questions tagged 'bash'" rel="tag">bash</a> v3.2.48(1)-release and can't upgrade.</p>
  
  <hr>
  
  <p>Some background:</p>
  
  <p>I have a friend with whome I am trying to study "some" Django.</p>
  
  <p>He's more clueless than me at the command line and needs the following, on OSX hackintosh:</p>
  
  <ul>
  <li>launch an interactive shell</li>
  <li>find the PATH variable including the django bin dir, as per my specification</li>
  <li>find an updated PYTHONPATH env var, with the various django libs visible</li>
  <li>a nice interactive ipython shell to start typing commands in after double-clicking</li>
  <li>(tricky) an interactive shell to fall back to once he CTRL-D exits from ipython</li>
  </ul>
  
  <p>On Windows, I would alias a command shortcut, like cmd.exe, set custom environment variables and start ipython. This works: after exiting ipython one still finds oneself in a command interpreter.</p>
  
  <p>Is this possible at all with OSX's standard bash? I played with bash -c but many things don't work, like changing into a directory, being able to exit python and <em>stay</em> in a terminal, etc. Also played with -s.</p>