On Fri, Jan 11, 2013 at 10:21:55PM +0800, Ma Shimiao wrote:
> I used commands as follows:
> $seq 5 | mapfile -C echo -c1
> 0 1
> 
> 1 2
> 
> 2 3
> 
> 3 4
> 
> 4 5
> 
> I would have expectd 1,2,3,4,5 above from the"help mapfile".
> Is it a bug of  mapfile?

The help says:

    When CALLBACK is evaluated, it is supplied the index of the next array
    element to be assigned and the line to be assigned to that element
    as additional arguments.

So your full callback command, executed on each item read, is:

  echo 'index number' 'line of input including newline'

echo adds an additional newline of its own.  The first array index number
is 0, which corresponds to the line containing $'1\n'.

Reply via email to