[mdlug] Evil eval

Michael Corral micorral at comcast.net
Fri Oct 3 21:05:42 EDT 2014


2014-10-01, Monsieur Jeff Hanson a ecrit:
> echo "Quotes first, escapes second:"
> for varname in test1a test1b test1c; do
>    eval echo "$varname""_lc: \$$varname\_lc"
> done

Try this:

echo "Quotes first, escapes second:"
for varname in test1a test1b test1c; do
     eval echo "$varname\_lc:" \$$varname\_lc
done


> echo "Escapes both:"
> for varname in test1a test1b test1c; do
>    eval echo "$varname\_lc: \$$varname\_lc"
> done

Try this:

echo "Escapes both:"
for varname in test1a test1b test1c; do
     eval echo $varname\_lc: \$$varname\_lc
done



Michael


More information about the mdlug mailing list