Re: Curious bash evaluation

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

 



On 12/27/10, Rodolfo Alcazar Portillo <nospaze@xxxxxxxxx> 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?
>
> Thanks...
> ----------------------------------------------
> Rodolfo Alcazar Portillo - nospaze@xxxxxxxxx
> otbits.blogspot.com / counter.li.org: #367962
> ----------------------------------------------
> # unzip; strip; touch; finger; grep; mount; fsck; more; yes; fsck; fsck;
> fsck; umount; sleep
>
>

I will do the short explanation

This expression does what I call Double expansion
 echo $($A)

First it expands    echo HI

Then it does the echo which yields   HI

In your second command

 echo 'hi'

It just echos   hi .. like it should

Sorry, if this doesn't sound real elegant..    Someone will give a
better description

HTH
Marvin J. Kosmal

Disclaimer: This email is not intended to provide medical advice,
diagnosis or treatment. Views expressed here do not necessarily
reflect those of Farmer Marvin or any of the hens.
-- 
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines

[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux