Re: Curious bash evaluation

2010-12-27 Thread inode0
On Mon, Dec 27, 2010 at 10:51 PM, Rodolfo Alcazar Portillo wrote: > 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' >>

Re: Curious bash evaluation

2010-12-27 Thread Rodolfo Alcazar Portillo
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 t

Re: Curious bash evaluation

2010-12-27 Thread Chris Tyler
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

Re: Curious bash evaluation

2010-12-27 Thread inode0
On Mon, Dec 27, 2010 at 11:30 AM, Rodolfo Alcazar Portillo wrote: > On Mon, 2010-12-27 at 10:46 -0600, inode0 wrote: >> On Mon, Dec 27, 2010 at 10:05 AM, Rodolfo Alcazar Portillo >> wrote: >> > Hello. See this: >> > >> > # A="echo 'hi'" >> > >> > # echo $($A) >> > 'hi' >> >> That seems rather con

Re: Curious bash evaluation

2010-12-27 Thread Rodolfo Alcazar Portillo
On Mon, 2010-12-27 at 10:46 -0600, inode0 wrote: > On Mon, Dec 27, 2010 at 10:05 AM, Rodolfo Alcazar Portillo > wrote: > > Hello. See this: > > > > # A="echo 'hi'" > > > > # echo $($A) > > 'hi' > > That seems rather convoluted. Are you sure you don't just want to > "eval $A" anyway? Very sure. N

Re: Curious bash evaluation

2010-12-27 Thread inode0
On Mon, Dec 27, 2010 at 10:05 AM, Rodolfo Alcazar Portillo wrote: > Hello. See this: > > # A="echo 'hi'" > > # echo $($A) > 'hi' That seems rather convoluted. Are you sure you don't just want to "eval $A" anyway? I realize your example may be a simple abstraction of something more complex. John

Re: Curious bash evaluation

2010-12-27 Thread Suvayu Ali
On Monday 27 December 2010 08:05 AM, Rodolfo Alcazar Portillo wrote: > Hello. See this: > > # A="echo 'hi'" I think this assignment makes the single quotes part of the string to be "echo"ed. Its is equivalent to saying, echo \'hi\'. If you don't want the single quotes echoed, don't use them insi

Re: Curious bash evaluation

2010-12-27 Thread Rodolfo Alcazar Portillo
On Mon, 2010-12-27 at 08:13 -0800, Marvin Kosmal wrote: > I will do the short explanation > This expression does what I call Double expansion > echo $($A) > First it expandsecho HI > Then it does the echo which yields HI Please read the former mail, it echoes the quotes. > In your second c

Re: Curious bash evaluation

2010-12-27 Thread Marvin Kosmal
On 12/27/10, 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? > > Is there any dark shopt option which makes it run correctly? > >

Curious bash evaluation

2010-12-27 Thread Rodolfo Alcazar Portillo
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? Is there any dark shopt option which makes it run correctly? Thanks... -- Rodolfo Alca