On 1/15/11 12:28 AM, Chris F.A. Johnson wrote: > On Mon, 17 May 2010, Chet Ramey wrote: > >> On 4/15/10 11:56 PM, DennisW wrote: >>> Mapfile would be that much more powerful if the callback function had >>> access to the current line. Is there any chance this might be added in >>> the future? >> >> Sure, there's a chance. What would be the most useful form? A shell >> variable that lives for the duration of the execution of the callback >> function? > > [A somewhat belated reply!] > > It appears that the assignment is made after the function is called > rather than before. I would like the value passed to the callback > function to be the index of the line just read (and already > assigned to the array).
Too belated, it seems. Bash-4.2 passes the line read and to be assigned to the array element as the second argument to the callback function. That means that mapfile -C "echo" -c 1 -t A numbers the input lines like `cat -n', but starting from 0, and leaves the result in A. 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/