Nathan Weeks
2014-03-26 14:10:40 UTC
The ksh 2014-01-14 man page states the following regarding arrays with
subscripts
* or @ :
========================================
${parameter}
...
If an array vname with last subscript * @, or for index arrays of the
form sub1 .. sub2.is used, then the value for each of the elements
between sub1 and sub2 inclusive (or all elements for * and @) is
substituted, separated by the
first character of the value of IFS.
========================================
However, the array elements appear to be separated by the first character of
IFS only for a * subscript, and only if the array vname is double-quoted:
========================================
$ array=(one two three)
$ (IFS=,; print -r ${array[@]})
one two three
$ (IFS=,; print -r ${array[0..2]})
one two three
$ (IFS=,; print -r ${array[*]})
one two three
$ (IFS=,; print -r "${array[@]}")
one two three
$ (IFS=,; print -r "${array[0..2]}")
one two three
$ (IFS=,; print -r "${array[*]}")
one,two,three
========================================
I suggest the man page be updated to reflect this behavior.
--
Nathan Weeks
IT Specialist
USDA-ARS Corn Insects and Crop Genetics Research Unit
Crop Genome Informatics Laboratory
Iowa State University
http://weeks.public.iastate.edu/
subscripts
* or @ :
========================================
${parameter}
...
If an array vname with last subscript * @, or for index arrays of the
form sub1 .. sub2.is used, then the value for each of the elements
between sub1 and sub2 inclusive (or all elements for * and @) is
substituted, separated by the
first character of the value of IFS.
========================================
However, the array elements appear to be separated by the first character of
IFS only for a * subscript, and only if the array vname is double-quoted:
========================================
$ array=(one two three)
$ (IFS=,; print -r ${array[@]})
one two three
$ (IFS=,; print -r ${array[0..2]})
one two three
$ (IFS=,; print -r ${array[*]})
one two three
$ (IFS=,; print -r "${array[@]}")
one two three
$ (IFS=,; print -r "${array[0..2]}")
one two three
$ (IFS=,; print -r "${array[*]}")
one,two,three
========================================
I suggest the man page be updated to reflect this behavior.
--
Nathan Weeks
IT Specialist
USDA-ARS Corn Insects and Crop Genetics Research Unit
Crop Genome Informatics Laboratory
Iowa State University
http://weeks.public.iastate.edu/