[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to do? Possible?
From: |
Eric Blake |
Subject: |
Re: How to do? Possible? |
Date: |
Mon, 25 Jul 2011 15:49:14 -0600 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110621 Fedora/3.1.11-1.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.11 |
On 07/25/2011 03:45 PM, Linda Walsh wrote:
I mistyped that but it brings me to an interesting
conundrum:
GLOBAL="hi there"
{foo=GLOBAL echo ${!foo}; }
This says:
evaluate ${!foo}, and pass that expansion to 'echo', with foo=GLOBAL in
the environment of echo. You are invoking behavior that POSIX leaves
undefined (that is, bash is perfectly fine evaluating ${!foo} prior to
assigning foo, but bash would also be okay if it assigned foo prior to
evaluating ${!foo}. Hence, you got no output.
But:
{ foo=GLOBAL;echo ${!foo}; }
> hi there
The extra ; forces the semantics. Here, the assignment to foo is a
different statement than the expansion of of ${!foo}. And while ${!foo}
is a bash extension, it still proves that this is a case where foo was
assigned prior to its use.
Weird...
Not if you think about it properly.
--
Eric Blake address@hidden +1-801-349-2682
Libvirt virtualization library http://libvirt.org
- How to do? Possible?, Linda Walsh, 2011/07/25
- Re: How to do? Possible?, Pierre Gaston, 2011/07/25
- Re: How to do? Possible?, Linda Walsh, 2011/07/25
- Re: How to do? Possible?, DJ Mills, 2011/07/25
- Re: How to do? Possible?, Linda Walsh, 2011/07/25
- Re: How to do? Possible?, Bob Proulx, 2011/07/25
- Re: How to do? Possible?, Linda Walsh, 2011/07/25
- Re: How to do? Possible?, Linda Walsh, 2011/07/25
- Re: How to do? Possible?,
Eric Blake <=
- Re: How to do? Possible?, Linda Walsh, 2011/07/25
- Re: How to do? Possible?, Bob Proulx, 2011/07/25
- Re: How to do? Possible?, Dennis Williamson, 2011/07/25
- Re: How to do? Possible?, Bob Proulx, 2011/07/25
- Re: How to do? Possible?, Dennis Williamson, 2011/07/26
- Re: How to do? Possible?, Davide Brini, 2011/07/25
- Re: How to do? Possible?, Pierre Gaston, 2011/07/25
Re: How to do? Possible?, Steven W. Orr, 2011/07/25