[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to do? Possible?
From: |
Dennis Williamson |
Subject: |
Re: How to do? Possible? |
Date: |
Mon, 25 Jul 2011 19:47:59 -0500 |
On Mon, Jul 25, 2011 at 4:45 PM, Linda Walsh <address@hidden> wrote:
>
>
> Linda Walsh wrote:
>>
>> Bob Proulx wrote:
>>> Yes, but it is a fork(2) of the parent shell and all of the variables
>>> from the parent are copied along with the fork into the child process
>>> and that includes non-exported variables. Normally you would expect
>>> that a subprocess wouldn't have access to parent shell variables
>>> unless they were exported. But with a subshell a copy of all
>>> variables are available.
>>>
>>> Bob
>> --
>> Not really.
>> It only seems that way because within () any "$xxxx" is usually
>> expanded BEFORE the () starts from the parent....
>>
>> You can see this by
>> GLOBAL="hi there"
>> (echo $GLOBAL)
>> prints out "hi there" as expected, but if we hide
>> $GLOBAL so it isn't seen by parent:
>> (foo=GLOBAL; echo ${!foo})
>> prints ""
> ---
> I mistyped that but it brings me to an interesting
> conundrum:
>
> GLOBAL="hi there"
> {foo=GLOBAL echo ${!foo}; }
>
>> (foo=GLOBAL echo ${!foo} )
>
> But:
>> { foo=GLOBAL;echo ${!foo}; }
> hi there
>> (foo=GLOBAL; echo ${!foo})
> hi there
> ----
> Weird...
>
>
>
I'm assuming you meant:
GLOBAL="hi there"
{foo=$GLOBAL echo ${!foo}; }
You had a missing dollar sign.
--
Visit serverfault.com to get your system administration questions answered.
- Re: How to do? Possible?, (continued)
- 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, 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?,
Dennis Williamson <=
- 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