On 8/29/13 12:42 PM, DJ Mills wrote:
> When using a non-default IFS (a default IFS would trim them), a single
> empty trailing field is ignored for read -a.
> 
> IFS=: read -rd '' -a arr < <(printf %s ':foo:bar:'); printf '<%s> '
> "${arr[@]}"; echo
> <> <foo> <bar>
> 
> I would expect the output to be:
> <> <foo> <bar> <>

The bash behavior is correct.  Characters in IFS are delimiters that are
treated as field *terminators* by word splitting, not technically as field
separators.  Posix-2013 (Issue 7 TC 1) clarifies this, and I just cribbed
some text from it for the bash documentation.

None of the special handling that sets variables to null strings takes
place, since there are not really more (or fewer) variables than fields.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    c...@case.edu    http://cnswww.cns.cwru.edu/~chet/

Reply via email to