puzzled
Bryan Cardoza
bcardoza at npd.Novell.COM
Thu Nov 29 04:09:05 AEST 1990
In article <1990Nov27.002845.3387 at informix.com> housed at infmx.informix.com (Darryl House) writes:
>The following is a Bourne shell script that illustrates
>what I am trying to do: set a shell variable that
>contains the contents of another one that is referred
>to by concatenating two others. Sufficiently confusing?
Pointer variables in Bourne shell? You mean like this?
#! /bin/sh
PREFIXES="alpha gamma"
SUFFIXES="beta delta"
alphabeta=1
alphadelta=2
gammabeta=3
gammadelta=4
for prefix in ${PREFIXES}
do
for suffix in ${SUFFIXES}
do
# Notice that the combination of "eval" and escaping
# the first "$" does the magic you want.
eval magic=\${${prefix}${suffix}}
echo ${magic}
done
done
Is this what you mean? (I've found this really usefull in calling
shell procedures with different global shell variable names as
arguments.)
--
Bryan Cardoza <Bryan_Cardoza at NPD.Novell.COM>
Software Engineer
Novell, Inc. Telephone: (801) 429-3149
Provo, UT Fax: (801) 429-3500
More information about the Comp.unix.internals
mailing list