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, the
result is that var1 is NOT changed. So, the result of the first echo
will be 0
However, the next echo displays the changed var1 as being 1. At the
expense of losing the return value.

Is there a "magic" way to let the bash functions behave as I would
expect? I need some functions who return a value but also alter other
global variables.

Kind regards,
Frans de Boer. 



_______________________________________________
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash

Reply via email to