home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.shell
- Path: sparky!uunet!utcsri!torn!maccs!mcshub!zooks!roy
- From: roy@zooks.eng.mcmaster.ca (Roy Underhill)
- Subject: Re: unwinding $variables in csh
- Message-ID: <1992Aug12.164213.7019@mcshub.dcss.mcmaster.ca>
- Summary: Use more than lines of code
- Keywords: resolve, unwind $variables, csh
- Sender: Roy Underhill
- Nntp-Posting-Host: zooks.eng.mcmaster.ca
- Organization: Dept. of Mech. Eng., McMaster University
- References: <1992Aug9.194325.1476@sol.UVic.CA>
- Date: Wed, 12 Aug 1992 16:42:13 GMT
- Lines: 41
-
- In article <1992Aug9.194325.1476@sol.UVic.CA> stilley@csr.UVic.CA (Scott Tilley) writes:
- >What is the easiest way to completely resolve variables in csh? I have
- >several variables that are made up of other $variables. I do not
- >want them expanded until the end of the script, so I use
- >
- > set var1 = '$HOME'
- > set var2 = '$var1/dir'
- >
- >for example. At the end of the script I need to propagate var2 to the
- >environment, such as
- >
- > setenv DIR $var2
- >
- >but this produces "$DIR = $HOME/dir", i.e., $HOME does not
- >get expanded. How can I get csh to fully expand all variables
- >in one shot?
- >
- > ..Scott
-
- This looks like one of those times when cleverness does not pay off.
- Rather than do something really neat that will magically convert it
- all at once, it is sometimes much easier to use more than one line of
- code. Alternatively just do your compounding all in the last line.
- eg
-
- set var1 = $HOME
- set var2 = /dir
- setenv DIR $var1$var2
-
- This is not quite what you asked for, but it does do the job.
-
- Good Luck,
-
-
- Roy
-
- --
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Roy Underhill, (416) 525-9140 x4395 roy@zooks.eng.mcmaster.ca
- Department of Mechanical Engineering, McMaster University,
- Hamilton, Ontario, Canada L8S 4L7
-