[Top][All Lists]

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

Re: Code for :"Re: HERE document failed && Re: /dev/fd/62: No such file

From: Greg Wooledge
Subject: Re: Code for :"Re: HERE document failed && Re: /dev/fd/62: No such file or directory"
Date: Tue, 29 Jul 2014 16:32:10 -0400
User-agent: Mutt/

On Tue, Jul 29, 2014 at 10:21:36PM +0200, Angel wrote:
> What surprises me is that the only use of here-docs (actually
> here-strings) in your script are process substitutions:
> > read out <<<$(declare -p "$var" )
> > while ... done <<<"$(get_net_IFnames_hwaddrs)"
> When it looks simpler to write the non-here version:
> > declare -p "$var" | read out
> > get_net_IFnames_hwaddrs | while ...

The 'read' example will not work as you've written it.  The change to
the shell variable 'out' will be lost when the pipeline terminates.
(But you can get a very recent bash release and set the "lastpipe"
shopt to work around this.)

If the while loop also tries to set shell variables, then it will have
the same problem (and the same possible workaround).

It looks like Linda's original script was doing something like this:

read out < <(declare -p "$var")

and she discovered that she couldn't use process substitutions in this
boot script (presumably because Linux's /dev/fd/ file system wasn't
mounted yet), so she tried to replace it with a here-document, and now has
learned that /tmp is not mounted (or is mounted read-only) at that point.

I won't even try to guess why she can't just do out=$var ... there is
probably some extremely silly reason that will just make me want to slam
my head into my desk....

reply via email to

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