On Wed, Jan 27, 2010 at 03:07:40PM +0200, Pierre Gaston wrote:
> On Wed, Jan 27, 2010 at 2:49 PM, Sharuzzaman Ahmat Raslan
> <sharuzza...@gmail.com> wrote:
> > Somehow, the backtick for foo() execute the function, echoing the correct
> > output, but fails to set the variable $gang to the correct value. Because of
> > that, the function bar() did not echoing anything because the variable $gang
> > is null.
> 
> `` and $() introduce subshells. The parent shell cannot be modified by
> the subshells.

For hints on working around this, see http://mywiki.wooledge.org/BashFAQ/084

The bad news is that it's pretty much impossible to capture stdout from
a function *and* set global variables at the same time.  You need to
choose one or the other, or use some file system object to store output.


Reply via email to