Here is a simple script, distilled from something actually useful, that works on fedora but not on OS X Lion.
declare -a directory_contents=($(ls .))
test -e ${directory_contents[0]}
echo $?
On linux it returns 0, i.e., test -e passes. On Mac, it returns 1.
Any idea what could be going wrong here?
What I neglected to clarify in my original question is that my “script” is really a bash function. The cause of my issue is that “ls” is resolving to an alias with “–color=auto”, adding unprintable characters to the actual filename.
Always define variables to hold the full path to the executables used in a script, e.g., “LS=/bin/ls”. And, per answers above, ls might not be you best choice for a robust production script.