Reading a delimited string into an array in Bash
In: arr=( $line )
. The "split" comes associated with "glob".
Wildcards (*
,?
and []
) will be expanded to matching filenames.
The correct solution is only slightly more complex:
IFS=' ' read -a arr <<< "$line"
No globbing problem; the split character is set in $IFS
, variables quoted.