Look at the following bash code:

#!/bin/bash
func ()
{
  echo "\"loc_var\" in func = $loc_var"
}

func2 ()
{
  echo "loc_var inside another function is" $loc_var
  local loc_var=23
  func
}

loc_var=43
func2

echo "\"loc_var\" outside function = $loc_var"
exit 0


If you run this, you'll notice that loc_var prints as 23.  It should print
as 43.
This is a problem with bash - that is if one function calls another the
value of the local variables are seen.

Does the C shell handle this correctly?

/*
PLUG: http://plug.org, #utah on irc.freenode.net
Unsubscribe: http://plug.org/mailman/options/plug
Don't fear the penguin.
*/

Reply via email to