The environment variable is split into "words" according to the value of $IFS
, and the "words" are joined with a single separator - in this case an ordinary space. Thus the sequence "\x09\x0a"
, or "\t\n",
is collapsed to one space ('\x20'
) when interpreting the contents of array
.
IFS - The Internal Field Separator that is used for word splitting after expansion and to split lines into words with the read builtin command. The default value is ''space tab newline''.
You can avoid the replacement by (temporarily) changing $IFS
.
Note, however, that
array[0]
has indeterminate valuearray
is not 0-terminated
in your programme. You should fix that.