Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!mips!daver!leadsv!iscnvx!wurtz From: wurtz@iscnvx.uucp (J D Wurtz) Newsgroups: comp.unix.questions Subject: C-shell script variable substitution problem/question Message-ID: <1991Jun24.230024.18513@iscnvx.uucp> Date: 24 Jun 91 23:00:24 GMT Reply-To: wurtz@iscnvx.UUCP (J D Wurtz) Distribution: usa Organization: LMSC - Information Services Lines: 49 I like scripts that are "forgiving", i.e., if I forget to supply an argument, I want the script to automatically prompt me for the missing information. I've run into a problem, however. Given the following: 1) the executable c-shell script named "sc": #!/bin/csh -f if ( $1 == "" ) then echo 'Name of the directory> \c' set dir = ($<) else set dir = $1 endif cat $dir/testfile # display the file 2) I'm currently in directory "/home/love" 3) the file named "testfile" is located in directory "/home/love/you" 4) the variable "ilu" is set to "/home/love/you" 5) IRIX System V Release 3.3.2. I then type the following to execute script "sc" in four different ways: 1) sc /home/love/you 2) sc Name of the directory> /home/love/you 3) sc $ilu 4) sc Name of the directory> $ilu Cases 1, 2, and 3 above all work very nicely, doing exactly what I want. Case 4, however, does not work because shell variable "ilu" is not substituted with its value (which is "/home/love/you"). Who can please tell me how to make the c-shell treat variable "ilu" the same for case (4) as it does for case (3)? Also, is this called "recursive substitution"? Many thanks for your assistance. -- Jeffrey D. Wurtz, Staff Engineer wurtz@sgi421.msd.lmsc.lockheed.com Structures, Orgn/81-12, Bldg/157 (408)756-1377 Lockheed Missiles and Space Company, Inc. Sunnyvale, CA 94088-3504