Curious bash evaluation
Rodolfo Alcazar Portillo
nospaze at gmail.com
Tue Dec 28 04:51:37 UTC 2010
On Mon, 2010-12-27 at 13:31 -0500, Chris Tyler wrote:
> On Mon, 2010-12-27 at 17:05 +0100, Rodolfo Alcazar Portillo wrote:
> > Hello. See this:
> >
> > # A="echo 'hi'"
> >
> > # echo $($A)
> > 'hi'
> >
> > # echo 'hi'
> > hi
> >
> > Does anyone understand why does the first command
> > evals the echo but echoes the simple quotes?
>
> $() provides a type of quoting, so it's evaluated similar to:
>
> "echo" "'hi'"
>
> which produces the observed result.
Hmmm. Somehow obvious. Is that "type of quoting" documented
somewhere? Why does it eval just the first word?
:)
----------------------------------------------
Rodolfo Alcazar Portillo - nospaze at gmail.com
otbits.blogspot.com / counter.li.org: #367962
----------------------------------------------
Q. How do you solve bus problems?
A. Shoot the driver.
More information about the users
mailing list