Consider the following program:

#!/usr/local/bin/bash --norc
export VAR=A
function setvar
{
  VAR=B
  echo X
}
V=$(setvar)
echo $VAR

When I execute it, I get as result "A", not "B", as I had expected.

If setvar would be an external program, I would understand the result,
as this would have to be run in a subshell; but it is a shell function,
and shell functions are supposed to be evaluated in the context of the
current environment. But it seems that within a $(...), even shell 
functions are executed in a child process. Is this supposed to work that

way?

Ronald, using bash 2.05b.
-- 
Ronald Fischer (phone +49-89-63676431)
mailto:[EMAIL PROTECTED]


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

Reply via email to