bug-bash
[Top][All Lists]
Advanced

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

Re: Assigning to multiple variables on same line


From: Mike Frysinger
Subject: Re: Assigning to multiple variables on same line
Date: Thu, 13 Aug 2009 14:24:51 -0400
User-agent: KMail/1.11.4 (Linux/2.6.30.3; KDE/4.2.4; x86_64; ; )

On Thursday 13 August 2009 09:04:32 Greg Wooledge wrote:
> On Thu, Aug 13, 2009 at 02:45:51AM -0400, Mike Frysinger wrote:
> > i dont think word expansion occurs first, otherwise wouldnt this break:
> > foo() {
> >     unset b c
> >     f="a b="
> >     local a=$f c=
>
> As I understand it, this is what happens:
>
> 1) The parser separates out the tokens that constitute the command.  These
>    are `local', `a=$f', and `c='.  The meaning of each token is determined.
>
> 2) Parameter expansion is performed on the $f.  But this can't create a
>    new token.  It's too late for that.  The whitespace becomes part of
>    the second token.  (If you wanted a new token, you'd have to use eval.)
>
> 3) The `local' command is actually executed, performing the assignments,
>    and returning its own exit status.

right, but i didnt think these were word expansions.  that's all my point was.
-mike

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


reply via email to

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