On Dec 30, 2016 11:20 PM, "Peter & Kelly Passchier" <
peterke...@passchier.net> wrote:
Thanks Dennis and Grisha! I understand.
I had thought that every line that is piped into bash is it's own shell
alignment, but I understand it's more like sourcing, so these would be
more or less equivalent,
I guess they are not equivalent, piping into bash opens a subshell, and
sourcing doesn't; these act differently:
echo exit |bash
echo exit >r; source r
Hope I've gotten it right now. Thanks,
Peter
On 31/12/2559 11:20, Peter & Kelly Passchier wrote:
> Thanks Dennis and Grisha! I understand.
>
Thanks Dennis and Grisha! I understand.
I had thought that every line that is piped into bash is it's own shell
alignment, but I understand it's more like sourcing, so these would be
more or less equivalent, right?
r=23; echo $r; echo -e 'r=bc\necho $r' >r; source r
r=23; echo $r; echo -e
On Fri, Dec 30, 2016 at 11:03 PM, PePa wrote:
r=23; echo $r; echo -e "r=bc\necho $r" |bash
You need to escape the $ in the second echo statement so that $r is not
evaluated to 23 before being echoed.
It seems that when piping into bash, variables have different
'retention' than functions:
r=23; echo $r; echo -e "r=bc\necho $r" |bash
23
23
r(){ echo Hey;}; r; echo -e "r(){ echo Ho;}\nr" |bash
Hey
Ho
Is this a bug, or is there a rationale?
Thanks,
Peter