View Single Post
  #2   (View Single Post)  
Old 21st September 2010
rocket357's Avatar
rocket357 rocket357 is offline
Real Name: Jonathon
Wannabe OpenBSD porter
 
Join Date: Jun 2010
Location: 127.0.0.1
Posts: 429
Default

Quote:
Originally Posted by cq04cw View Post
PHP Code:
b=$( eval echo \$$_var )   # this method as expected
b=`eval echo \$$_var`    # this method not as expected ,should it be same result as previous method? 
On OpenBSD-CURRENT, which exhibits the same behavior:

Quote:
Originally Posted by man ksh
For $(command) substitutions, normal quoting rules are used when command is parsed; however, for the `command` form, a `\' followed by any of `$', ``', or `\' is stripped (a `\' followed by any other character is unchanged).
Simply put, for `command` form substitution, \$ is treated in a special manner and what you get from \$$ is $$, or the pid of the shell you're working in right now.

PHP Code:
$ echo $$
21638
ksh
$ echo $$
12413
$ exit
$ echo $$
21638 
This, however, works:

PHP Code:
b=`eval echo \\$$_var

Last edited by rocket357; 21st September 2010 at 02:27 PM.
Reply With Quote