help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] Bug? Explanation??


From: Dennis Williamson
Subject: Re: [Help-bash] Bug? Explanation??
Date: Fri, 30 Dec 2016 22:10:50 -0600

On Dec 30, 2016 11:04 PM, "PePa" <address@hidden> wrote:

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


It's because you have the echo argument inside double quotes and the
variable is expanded before the echo or the piped bash are executed. Change
to single quotes and the expansion will be delayed.


reply via email to

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