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
"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
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