bug-bash
[Top][All Lists]
Advanced

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

Re: mapfile documentation


From: Greg Wooledge
Subject: Re: mapfile documentation
Date: Fri, 16 Mar 2018 15:55:05 -0400
User-agent: NeoMutt/20170113 (1.7.2)

On Fri, Mar 16, 2018 at 03:45:42PM -0400, Boruch Baum wrote:
> 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?

No, your construction (foo | readarray) only works with those two
settings changed.  A different construction (e.g. readarray < <(foo))
works just fine.

> That
> sounds like quite a 'gotcha' and isn't mentioned in the man page
> documentation for mapfile. Do you think it should be? Should I continue
> this now on-list and ask for it to be mentioned?

Ultimately Chet gets to decide which common shell programming failures
are worthy of being mentioned in the (already huge) manual.  The man
page is not meant to be a tutorial for how to write bash scripts.
It's meant as a reference.



reply via email to

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