[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Mapfile callback access to current line

From: DennisW
Subject: Re: Mapfile callback access to current line
Date: Wed, 08 Dec 2010 15:48:20 -0000
User-agent: G2/1.0

On May 17, 4:42 pm, Chet Ramey <address@hidden> 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?
> Chet
> --
> ``The lyf so short, the craft so long to lerne.'' - Chaucer
>                  ``Ars longa, vita brevis'' - Hippocrates
> Chet Ramey, ITS, CWRU   address@hidden    http://cnswww.cns.cwru.edu/~chet/

Yes. The proposed variable's value should be modifiable and the
modified value would be the one that is stored in the array specified
in the mapfile command (by default: ARRAY).

foo () { MAP_LINE=${MAP_LINE%bar*}; }
mapfile -C foo -c 1 -t filedata < file

Of course, this can be done in a while loop instead.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]