[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: variable assignment in string returning function
From: |
Pierre Gaston |
Subject: |
Re: variable assignment in string returning function |
Date: |
Wed, 27 Jan 2010 15:07:40 +0200 |
On Wed, Jan 27, 2010 at 2:49 PM, Sharuzzaman Ahmat Raslan
<sharuzzaman@gmail.com> wrote:
> Hi,
>
> I found the behaviour of the function below is a little bit odd. Appreciate
> if someone can share his/her knowledge regarding the behaviour.
>
> The output of the script will be:
>
> sharuzzaman@debian:~$ ./case1.sh
> Nice behaviour,
>
> 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.