I'm having problems in bash (ver 4.2.25) copying arrays with empty elements. When I make a copy of an array into another variable, it does not copy any empty elements along with it.
#!/bin/bash
array=( 'one' '' 'three' )
copy=( ${array[*]} )
IFS=$'\n'
echo "--- array (${#array[*]}) ---"
echo "${array[*]}"
echo
echo "--- copy (${#copy[*]}) ---"
echo "${copy[*]}"
When I do this, here is the output:
--- array (3) ---
one
three
--- copy (2) ---
one
three
The original array has all three elements including the empty element, but the copy does not. What am I doing wrong here?