Building Variable Names in Bourne Shell

Erik Naggum erik at naggum.se
Sun Mar 27 03:56:25 AEST 1988


I thought this was obvious for the -wizards, so I sent
kevinc at bearcat.lim.tek.com a private reply.

The right thing to do is _eval_.  No . or exec will do the job very fast.

	var='$'${foo}bar
	eval echo '$var = ' $var

The very purpose of eval is to reevaluate the command line.  (That is,
first evaluate the arguments, then execute them, i.e. evaluate them once
more.)

To everyone of those who have proposed wierd solutions:
Go read "An introduction to the UNIX Shell" by S. R. Bourne.
(Sorry if this offends anyone, but negligence on the part of reading
manuals is what I consider the hallmark of the novice.  Besides, I learn
more and more things from reading the same manuals over and over.)

Yours in hacking (nonpejorative meaning),
Erik Naggum
UUCP  --   erik at naggum.uucp		UNIX is not ``eunuchs'' --  
ARPA  --   enag at ifi.uio.no		in fact it's rather potent
Snail --   Naggum Software; POB 1560 VIKA; OSLO 0118; NORWAY; +47-2-384-400



More information about the Comp.unix.wizards mailing list