On Fri, Dec 29, 2006 at 11:43:14PM +0100, Frans de Boer wrote:
> Yes, I did expected such an answer of using a subshell, and yes I can
> get the return value, but I don need it. I need the output fed into
> another (maybe local) variable. I was under the impression that BASH was
> modeled after 'C'
Yes, I did expected such an answer of using a subshell, and yes I can
get the return value, but I don need it. I need the output fed into
another (maybe local) variable. I was under the impression that BASH was
modeled after 'C', so I started using the functions as such. My mistake.
I have the conf
Frans de Boer <[EMAIL PROTECTED]> writes:
> Okay, the function tries to alter the global var1 integer. But, the
> result is that var1 is NOT changed.
Yes, because the function is executed in a subshell.
> So, the result of the first echo
> will be 0
> However, the next echo displays the changed
My example problem using Bash 3.00.16 (Suse 9.3)
#!
declare -i var1=2
function dowhat () {
local -i i=0
.
.
var1=$((var1+1))
echo $i
}
iretval=$(dowhat argument)
echo $var1
dowhat argument
echo $var1
-
Okay, the function tries to alter the global var1 integer. But