Passing a variable name to be created within a function

Is it possible to pass a variable name, as a parameter to a function, so it can be created within this function ?

Something like this:

func_uppercase abcdefgh var_name

where the 1st parameter is the string I want to convert and the 2nd is the desired variable name...

$2=`echo "$1" | $TR_PATH "[:lower:]" "[:upper:]"`

(TR_PATH contains the path of the tr that accepts these options...
TR_PATH='/usr/bin/tr')

I tried to run this and it returns a msg like:

var_name="string..." : not found

I'm using ksh under Sun OS...

Thanks anyway !

Someone's bound to reply who knows how to do this and negate my answer... :wink:

... but in short I don't know how and can't imagine why you'd want to. Any reason inparticular you're trying to do this? If the first parameter is, for example, a name you're passing to the script, it seems alot easier to me to just script name="$1" and call it a day.

First of all, you don't need a tr process. ksh can upshift all by itself.

typeset -u xyz
a="abc"
xyz=$a
echo $xyz

And you can use eval to build a command then execute it.
var="xyz"
eval typeset -u $var
a="abc"
eval $var=\$a
eval echo \$$var

But I too don't know why you'd want to do this.