This has to do with the variable IFS in bash. by default:
This means essentially that all tabs and newlines are translated to spaces when variables are assigned that value because space is the first character in IFS. Also it means that spaces, tabs, and newlines represent separators. (IFS I believe stands for internal field separator)
so the following script should work:
Code:
IFS=$'\n'
dapoutputarray=( $(su - dcmbox -c "$dcdldapstr") )
echo "0=${ldapoutputarray[0]}"
echo "1=${ldapoutputarray[1]}"
echo "2=${ldapoutputarray[2]}"
echo "3=${ldapoutputarray[3]}"
unset IFS
So only newlines are considered to be array field separators.
hope this helps