Com MN PG P E B Consultant 3 wrote: > 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.
Posix requires that command substitution be executed in a "subshell environment." It forbids changes to the subshell environment affecting the calling shell's environment. The way to do that is to run command substitutions in an actual subshell and communicate via pipes. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer Live Strong. No day but today. Chet Ramey, ITS, CWRU [EMAIL PROTECTED] http://cnswww.cns.cwru.edu/~chet/ _______________________________________________ Bug-bash mailing list Bug-bash@gnu.org http://lists.gnu.org/mailman/listinfo/bug-bash