Great. Please mark the thread as solved.
Oh, and I almost forgot, be sure to always
quote your variable expansions, otherwise shell word-splitting will take place (with a few minor exceptions, such as inside [[..]]
while read -r input ; do
[[ $input == quit ]] && break
array+=( "$input" )
Without the quotes, the initial $input
value will be split into multiple
array elements, and the final echo
command will have all entries printed with only single spaces between them, regardless of their original formatting.
It's vital in scripting to understand how the shell handles arguments and whitespace. Learn how to do it right!