help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] How to make variable set in () accessible outside?


From: Bob Proulx
Subject: Re: [Help-bash] How to make variable set in () accessible outside?
Date: Thu, 3 May 2012 00:43:47 -0600
User-agent: Mutt/1.5.21 (2010-09-15)

Peng Yu wrote:
> (export XXX=a)
> echo $XXX
> 
> In the above code, the echo command will print nothing. I'm wondering
> if there is a way make the variable set in () accessible outside.

The entire point of using a subshell with (...) is to make all
variables local to that subshell.  If you want to export variables
then don't use a subshell which by definition makes variables local.
Instead do whatever operation you want to do inside of the current
process.

Bob



reply via email to

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