Basically, it’s exactly as you’d do for returning a single value from a function (use echo) – but, you need to make sure you surround the variable with quotes (in the function – echo "${array[*]}"), and receive it as an array – out2=($(fnGo)).

Note you can only either choose to use an iterator method (out1), or an addressing method (out2), but not both – run the script and you’ll see what I mean.

Oh, one more thing (just as a tip for those who don’t already know) – pay attention to your IFS variable (which determines how parameters are separated)! This is especially important if you’re taking in quoted (escaped) command-line parameters that may have a space in them (such as file names) – in that case, I normally use "n".

—- Update (2009-10-03 @ 10:35:27) —-

Ok, having written bash scripts for a little while now, I have found a better way of doing this by using a special "return" variable; the old method will not let you actually echo anything onto the console and do things like "exit 1", but the following will: