[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Data piped to 'mapfile', 'readarray', 'read -a' shell builtins is ig
From: |
Greg Wooledge |
Subject: |
Re: Data piped to 'mapfile', 'readarray', 'read -a' shell builtins is ignored |
Date: |
Wed, 24 Mar 2010 10:16:05 -0400 |
User-agent: |
Mutt/1.4.2.3i |
On Wed, Mar 24, 2010 at 04:10:41PM +0200, Pierre Gaston wrote:
> On Wed, Mar 24, 2010 at 12:43 AM, Rob Robason <rob@robason.net> wrote:
> > $ ls -a | readarray # using the default MAPFILE array
> It's a faq, commands in a pipe are executed in a subshell and don't modify
> the parent shell.
And the workaround for this is to use process substitution:
readarray < <(your command)
(Don't use ls -a for this. Horrible example. If you want to stuff an
array with files, just use array=(*) instead, possibly turning on dotglob
and/or nullglob first.)