evaluating ${10} and above in sh/ksh

Chris Bertin chrisb at risky.Convergent.COM
Sat Aug 11 03:58:37 AEST 1990


There doesn't seem to be a way, in sh or ksh, to evaluate $10 and higher.
$10 and higher are evaluated as ${1}0, ${1}1, etc...
		     instead of ${10}, ${11}, etc...
I have tried many different ways and they all fail. Do you know one
that will work?

#! /bin/sh

set a b c d e f g h i j k l

arg=0

while [ $arg -le $# ]; do
	echo "evaluating \$$arg"
	eval echo $"$arg"
	eval echo $"${arg}"
	eval echo "$`eval echo $arg`"
	# Now, some of the crazy things I tried.
	# ( The parens are there when eval causes an error )
	echo "\${$arg} results in \c"
	( eval echo "\${$arg}" )
	echo "$`echo '{'``eval echo $arg``echo '}'` results in \c"
	( eval echo "$`echo '{'``eval echo $arg``echo '}'`" )
	arg=`expr $arg + 1`
done
-- 
Chris Bertin		|   chrisb at risky.Convergent.COM
Unisys			|		or
(408) 435-3762		| ...!uunet!pyramid!ctnews!risky!chrisb



More information about the Comp.unix.wizards mailing list