DaemonForums  

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
aa=AAAA
_var=aa    # set $_var to aa
_var=aa
$ echo ${aa}
+ echo 
AAAA
AAAA
$ echo ${_var}
+ echo 
aa
aa
$ echo ${b}
+ echo

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

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 06:21 PM.


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