home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / unix / shell / 3465 < prev    next >
Encoding:
Text File  |  1992-08-12  |  1.7 KB  |  56 lines

  1. Newsgroups: comp.unix.shell
  2. Path: sparky!uunet!utcsri!torn!maccs!mcshub!zooks!roy
  3. From: roy@zooks.eng.mcmaster.ca (Roy Underhill)
  4. Subject: Re: unwinding $variables in csh
  5. Message-ID: <1992Aug12.164213.7019@mcshub.dcss.mcmaster.ca>
  6. Summary: Use more than lines of code
  7. Keywords: resolve, unwind $variables, csh
  8. Sender: Roy Underhill
  9. Nntp-Posting-Host: zooks.eng.mcmaster.ca
  10. Organization: Dept. of Mech. Eng., McMaster University
  11. References: <1992Aug9.194325.1476@sol.UVic.CA>
  12. Date: Wed, 12 Aug 1992 16:42:13 GMT
  13. Lines: 41
  14.  
  15. In article <1992Aug9.194325.1476@sol.UVic.CA> stilley@csr.UVic.CA (Scott  Tilley) writes:
  16. >What is the easiest way to completely resolve variables in csh? I have
  17. >several variables that are made up of other $variables. I do not
  18. >want them expanded until the end of the script, so I use
  19. >
  20. >    set var1 = '$HOME'
  21. >    set var2 = '$var1/dir'
  22. >
  23. >for example. At the end of the script I need to propagate var2 to the
  24. >environment, such as
  25. >
  26. >    setenv DIR $var2
  27. >
  28. >but this produces "$DIR = $HOME/dir", i.e., $HOME does not
  29. >get expanded. How can I get csh to fully expand all variables
  30. >in one shot?
  31. >
  32. >    ..Scott
  33.  
  34. This looks like one of those times when cleverness does not pay off.
  35. Rather than do something really neat that will magically convert it
  36. all at once, it is sometimes much easier to use more than one line of
  37. code.  Alternatively just do your compounding all in the last line.
  38. eg
  39.  
  40. set var1 = $HOME
  41. set var2 = /dir
  42. setenv DIR $var1$var2
  43.  
  44. This is not quite what you asked for, but it does do the job. 
  45.  
  46. Good Luck,
  47.  
  48.  
  49. Roy
  50.  
  51. -- 
  52.    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
  53.   Roy Underhill,  (416) 525-9140 x4395   roy@zooks.eng.mcmaster.ca 
  54.   Department of Mechanical Engineering,  McMaster University, 
  55.   Hamilton,  Ontario,  Canada            L8S 4L7
  56.