Is it possible to declare and export a bash array from a single statement within a function?
My current workaround is to first declare, then to export.
f() { foo=(1 2 3); export foo; }; f; export -p | grep foo=
declare -ax foo='([0]="1" [1]="2" [2]="3")'
I observe that:
f() { export bar=(1 2 3); }; f; export -p | grep bar=
<no output>
and:
f() { export baz="(1 2 3)"; }; f; export -p | grep baz=
declare -x baz="(1 2 3)" # not an array
I use bash v3.2.48(1)-release and can't upgrade.
Some background:
I have a friend with whome I am trying to study "some" Django.
He's more clueless than me at the command line and needs the following, on OSX hackintosh:
- launch an interactive shell
- find the PATH variable including the django bin dir, as per my specification
- find an updated PYTHONPATH env var, with the various django libs visible
- a nice interactive ipython shell to start typing commands in after double-clicking
- (tricky) an interactive shell to fall back to once he CTRL-D exits from ipython
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.
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 stay in a terminal, etc. Also played with -s.
bazsobazis categorically not an array.