the function bar() did not echoing anything because the variable $gang
> > is null.
>
> > I would expect that $gang is set with the correct value and function bar()
> > will work after that.
> ...
> > #startscript--
> > #!/bin/bash
>
> > # test case f
expect that $gang is set with the correct value and function bar()
> will work after that.
...
> #startscript------
> #!/bin/bash
>
> # test case for variable assignment in string returning function
> # case 1: function with echo
>
> name="optimus"
>
>
> I would expect that $gang is set with the correct value and function bar()
> will work after that.
>
> Thanks.
>
>
> System information:
>
> OS: Debian Squeeze
> Hardware: Intel x86 Pentium 4
> Bash: 4.1.0(1)-release (i486-pc-linux-gnu)
>
>
>
&g
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
> 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
> > tha
Sharuzzaman Ahmat Raslan a écrit :
>
> Somehow, the backtick for foo() execute the function, echoing the correct
> output, but fails to set the variable $gang to the correct value.
The variable is set, but in a different sub shell. backticks fork a sub shell.
By the way $( ) is preferred to back
On Wed, Jan 27, 2010 at 2:49 PM, Sharuzzaman Ahmat Raslan
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:
>
> sharuzza...@debian:~$ ./case1.sh
> Nice
:
OS: Debian Squeeze
Hardware: Intel x86 Pentium 4
Bash: 4.1.0(1)-release (i486-pc-linux-gnu)
#startscript--
#!/bin/bash
# test case for variable assignment in string returning function
# case 1: function with echo
name="optimus"
foo () {
if [ "$name" = "opt