bug-bash
[Top][All Lists]
Advanced

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

Re: mapfile documentation


From: L A Walsh
Subject: Re: mapfile documentation
Date: Fri, 16 Mar 2018 18:13:16 -0700
User-agent: Thunderbird



Boruch Baum wrote:
I'm afraid what prompted me to file the report was something more
subtle. Upon trying my test one-liner on a second virtual terminal, the
one-liner worked, so I'm now trying to figure out what settings might
affect the behavior. My test one-liner is:

      printf "aa bb\n cc\n" | readarray ; echo ${MAPFILE[0]}

On 2018-03-16 14:59, Greg Wooledge wrote:
> > wooledg:~$ set +m
> > wooledg:~$ echo hello world | readarray; declare -p MAPFILE
> > declare -a MAPFILE=([0]=$'hello world\n')
> >
> > lastpipe will typically work in a script, because job control (set +m)
> > is disabled in scripts by default.  The reverse is true in an interactive
> > shell.
So that's it, then? On the command line, readarray only works with > "shopt -s lastpipe ; set +m", neither of which is set by default?
---
Boruch, could you 'Cc' or send a copy of your stuff to the list so the rest
of us could see it?


If you want to try your experiment, maybe you want:

readarray < <(printf "aa bb \n cc\n") ; echo 0=${MAPFILE[0]},
1=${MAPFILE[1]}
0=aa bb , 1= cc

Note, the trailing space after 'bb' and preceeding space before 'cc' as
exist in your text.  readarray can read the stdout of your printf that way.

Is that what you wanted?




reply via email to

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