bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bug? Explanation??


From: Peter & Kelly Passchier
Subject: Re: Bug? Explanation??
Date: Sat, 31 Dec 2016 11:28:30 +0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1

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 <address@hidden
>> <mailto:address@hidden>> 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.
>>
>> ‚Äč
> 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]