[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] How to set IFS temporarily? (along with assignment and a
From: |
Geir Hauge |
Subject: |
Re: [Help-bash] How to set IFS temporarily? (along with assignment and array initiation) |
Date: |
Mon, 16 Mar 2015 20:24:42 +0100 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
On Mon, Mar 16, 2015 at 02:45:30PM -0400, Chet Ramey wrote:
> On 3/16/15 12:57 PM, Greg Wooledge wrote:
> > On Mon, Mar 16, 2015 at 11:49:46AM -0500, Peng Yu wrote:
> >> I'm trying to understand readarray. It can only separate elements by
> >> newline. What about separating the elements by $'\0'? Is there an
> >> option for this case (I don't find it in the man page)?
> >
> > Unfortunately, no. That's one of my top wishlist features. If you
> > want to read elements delimited by anything other than \n you have to
> > use a loop.
>
> Look at the devel branch. mapfile/readarray acquired a `-d delim' option
> in early July, 2015.
That's great! Might I suggest also changing the -t option to:
Remove a trailing delimiter from each line read.
So that the following two commands give the same result:
mapfile -t array < <(printf 'a\nb\n')
mapfile -t -d X array < <(printf 'aXbX')
--
Geir Hauge