eval

hi all,
Am trying to add some code to a ksh script and i dont understand how an eval function is used :


_var=$1
    _conceal=$2

    eval _val=\$${_var}

can someone shed some light on what the eval function in the above context means/does ??

thanks.

It's setting _val to the value of the variable whose name is currently in _var

e.g. if _var is PATH is will set _val to contain the value of $PATH

Might be interesting to add:

echo $_val

to the bottom of this script and then call it with the params HOME testing or _conceal "my value"

For the first and last uses of _var in the quoted text, I believe Chubler_XL meant _val :wink:

Cheers,
Alister

1 Like

Thanks Alister,

I read the line

eval _val=\$${_var}

as

eval _var=\$${_var}

more than one too, guess I just saw what I expected. I've corrected my original post.

color tags don't work in icode for some reason, just code.