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. > > 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 'r=bc\necho $r' |bash > > Thanks again, > Peter > > > On 31/12/2559 11:07, Grisha Levit wrote: >> On Fri, Dec 30, 2016 at 11:03 PM, PePa <peterke...@passchier.net >> <mailto:peterke...@passchier.net>> 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. >> >> >