Re: Why is this executed inside a subshell?

2006-11-27 Thread Chet Ramey
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 subst

Re: Why is this executed inside a subshell?

2006-11-27 Thread Paul Jarc
"Com MN PG P E B Consultant 3" <[EMAIL PROTECTED]> wrote: > But it seems that within a $(...), even shell functions are executed > in a child process. Is this supposed to work that way? Yes. $() passes the output of the inner command to the outer shell via a pipe, with the inner command running i

Why is this executed inside a subshell?

2006-11-27 Thread Com MN PG P E B Consultant 3
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