bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: variable variable name


From: Paul Jarc
Subject: Re: variable variable name
Date: Thu, 07 Feb 2002 14:26:25 -0500
User-agent: Gnus/5.090006 (Oort Gnus v0.06) Emacs/20.7 (i386-redhat-linux-gnu)

"Matt P." <address@hidden> wrote:
> NAME=chet
> MEAL=pizza
> eval $NAME.meal=$MEAL

That would be fine except that "chet.meal" is not a valid variable
name.  Try this instead:
eval "${NAME}_meal="'"$MEAL"'
eval 'echo "$'"${NAME}"'_meal"'

(This version also ensures that the contents of $MEAL are not
re-expanded.)


paul



reply via email to

[Prev in Thread] Current Thread [Next in Thread]