[comp.unix.internals] puzzled

bcardoza@npd.Novell.COM (Bryan Cardoza) (11/29/90)

In article <1990Nov27.002845.3387@informix.com> housed@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@NPD.Novell.COM>
Software Engineer
Novell, Inc.                                   Telephone: (801) 429-3149
Provo, UT                                            Fax: (801) 429-3500