[comp.unix.wizards] How variables can be specified as arguments

skdutta@cs.tamu.edu (Saumen K Dutta) (08/10/90)

Pardon my ignorance wizards! I am confronted with a very simple
and tricky problem which I am not able to solve. The problem
comes with the following shell script:

--------------------------------------------
#! /bin/sh

read_KEY1() { echo -n "Key => " ; read key;
                         while  [ -z "$key" ]
                        do
                                echo Key cannot be blank , Type again
                                echo -n "Key => " ; read key;
                        done
                        }   
 
 
 
read_KEY1 
echo "The Key is: " $key
------------------------------------------

This will just ask you for the value of key until you type something.

The problem is to pass the string as a parameter and let 
it assign value the user types into it. 

e.g. 

read_KEY1 "key" 

should define a new variable called key and
assigns it's value according to what user types.

I am not able to solve this ! Please help me

-- the dumbo


--
     _                                   ||Internet: skdutta@cssun.tamu.edu  
    (   /_     _ /   --/-/- _            ||Bitnet : skd8107@tamvenus.bitnet 
   __)_/(_____(_/_(_/_(_(__(_/_______    ||Uucp : uunet!cssun.tamu.edu!skdutta
                                 ..      ||Yellnet: (409) 846-8803

chet@cwns1.CWRU.EDU (Chet Ramey) (08/11/90)

In article <7298@helios.TAMU.EDU> skdutta@cs.tamu.edu (Saumen K Dutta) writes:

$ read_KEY1 "key" 
$ 
$ should define a new variable called key and
$ assigns it's value according to what user types.
$ 
$ I am not able to solve this ! Please help me

Use `eval'.

Chet

-- 
Chet Ramey				``Levi Stubbs' tears run down
Network Services Group			  his face...''
Case Western Reserve University	
chet@ins.CWRU.Edu