[comp.unix.questions] Eval troubles in sh

pfalstad@phoenix.Princeton.EDU (Paul John Falstad) (09/14/90)

In article <1990Sep13.181238.4388@ecn.purdue.edu> irick@ecn.purdue.edu (GarBear Irick) writes:
>one=YES
>VAR=one
>eval echo VAR from echo: \$$VAR
>tmp1=`eval echo \$$VAR`
>eval tmp2=`eval echo \$$VAR`
>echo TMP1: $tmp1
>echo TMP2: $tmp2

sh removes backslashes inside backquotes.  Try these lines instead:

tmp1=`eval echo \\\$\$VAR`
eval tmp2=`eval echo \\\$\$VAR`

This will produce YES both times.

  David Hemmings appeared by permission of the National Forestry Commission.