bug-bash
[Top][All Lists]
Advanced

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

Re: bash uses tmp files for inter-process communication instead of pipes


From: Greg Wooledge
Subject: Re: bash uses tmp files for inter-process communication instead of pipes?
Date: Tue, 7 Oct 2014 08:29:21 -0400
User-agent: Mutt/1.4.2.3i

On Mon, Oct 06, 2014 at 04:04:25PM -0700, Linda Walsh wrote:
> Greg Wooledge wrote:
> >netdev_pat=... # (and other variable assignments)
> >(cd "$sysnet" &&
> >for ifname in ...; do
> >    hwaddr=$(<"$ifname"/address)
> >    act_hw2if[$hwaddr]="$ifname"
> >    act_if2hw[$ifname]="$hwaddr"
> >done)
> 
> Except that either act_hw2if + pair were just assigned to
> in the sub process that was meant to isolate the change
> of directory from the rest of the program,
> OR
> we aren't in the right directory when we do the reads.

OK, then use a function to give you an escapable block:

declare -A ...
create_maps() {
    cd "$sysnet" || return
    for ifname in ...; do
        hwaddr=$(<"$ifname"/address)
        act_hw2if[$hwaddr]="$ifname"
        act_hw2if[$ifname]="$hwaddr"
    done
}
create_maps

> Either way, they code as you have suggested won't work
> without overcoming another set of side effects.

There are ways to NOT use subshells.  I have given you two of those
ways now.



reply via email to

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