On Monday 10 August 2009 15:25:23 Chet Ramey wrote:
> Yang Zhang wrote:
> > Why does assigning to multiple variables on the same line exhibit
> > sequential consistency normally but not for local variables?
>
> Because `local' is a command, and word expansion is performed on its
> arguments before it's invoked.  This means the expansion is performed
> before `local' performs the assignment (local sees two arguments:
> `a=x' and `b=').  Variable assignments by themselves behave differently --
> expansion and assignment are done at the same time.

i dont think word expansion occurs first, otherwise wouldnt this break:
foo() {
        unset b c
        f="a b="
        local a=$f c=
        echo a:$a
        echo b:${b+set}
        echo c:${c+set}
}

it certainly works with bash, as does `declare` ... that is, we see:
a:a b=
b:
c:set
-mike

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to