B
blah
Guest
When I prefix [cmd=]while[/cmd] loop with pipe sh eats my global variable assigned inside the loop body
So, it's visible inside loop but not outside. Why it's invisible only when as part of a pipe?
In zsh it's visible in both cases.
8-CURRENT r194410M amd64 here.
Code:
$ echo baz | while true; do foo=blah; echo $foo; break; done
blah
$ echo $foo
$
Code:
$ while true; do foo=blah; echo $foo; break; done
blah
$ echo $foo
blah
$
8-CURRENT r194410M amd64 here.