Go Back   DaemonForums > Miscellaneous > Programming

Programming C, bash, Python, Perl, PHP, Java, you name it.

Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1   (View Single Post)  
Old 21st September 2010
cq04cw cq04cw is offline
New User
Join Date: Sep 2010
Posts: 5
Unhappy is there difference between two variations of sh command substitution?

PHP Code:
set -x     # open xtrace option to help for debugging
aa=AAAA   # set $aa to AAAA
_var=aa    # set $_var to aa
$ echo ${aa}
+ echo 
$ echo ${_var}
+ echo 
$ echo ${b}
+ echo

b=$( eval echo \$$_var )   # this method as expected
+ eval echo '$aa'
+ echo AAAA
$ echo ${b}
+ echo 
b=`eval echo \$$_var`    # this method not as expected ,should it be same result as previous method? 
+ eval echo 1401_var
+ echo 1401_var
$ echo ${b}
+ echo 

ref to "http://www.freebsd.org/cgi/man.cgi?query=sh&manpath=FreeBSD+8.1-RELEASE" command substitution section
environment ===
FreeBSD abc.xyz.com 8.1-RELEASE FreeBSD 8.1-RELEASE #0: Mon Jul 19 02:55:53 UTC 2010 root@almeida.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC i386
Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Striking difference between the Linux community and BSD windependence Off-Topic 79 6th December 2010 02:04 AM
What's the difference between these two memory modules? Carpetsmoker General Hardware 2 25th November 2008 03:13 PM
difference between jdk16 and diablo 1.6 cuongvt FreeBSD Ports and Packages 8 16th October 2008 12:17 AM
difference between rc.conf and loader.conf disappearedng FreeBSD General 5 3rd September 2008 05:54 AM
Difference between chpass and pw disappearedng FreeBSD General 9 7th July 2008 11:12 PM

All times are GMT. The time now is 09:45 PM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick