home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / unix / shell / 3478 < prev    next >
Encoding:
Internet Message Format  |  1992-08-13  |  1011 b 

  1. Path: sparky!uunet!olivea!news.bbn.com!news.bbn.com!news
  2. From: cjross@bbn.com (chris ross)
  3. Newsgroups: comp.unix.shell
  4. Subject: Re: unwinding $variables in csh
  5. Keywords: resolve, unwind $variables, csh
  6. Message-ID: <l8kop0INNkpq@news.bbn.com>
  7. Date: 13 Aug 92 13:26:56 GMT
  8. References: <1992Aug9.194325.1476@sol.UVic.CA>
  9. Lines: 20
  10. NNTP-Posting-Host: bbn.com
  11.  
  12. stilley@csr.UVic.CA (Scott  Tilley) writes:
  13.  
  14. >What is the easiest way to completely resolve variables in csh? I have
  15. >several variables that are made up of other $variables. I do not
  16. >want them expanded until the end of the script, so I use
  17.  
  18. >    set var1 = '$HOME'
  19. >    set var2 = '$var1/dir'
  20.  
  21. Use a while/eval loop, with continuation conditional on
  22. the presence of '$' in your variable:
  23.  
  24. while ($var2 =~ *\$*)
  25.     eval "set var2 = $var2"
  26. end
  27.  
  28.  
  29. chris ross   <cjross@bbn.com>   BBN Advanced Simulations   (617) 873-3272
  30.  WARNING: article may contain flammable material.  Do not expose to open
  31.    flames.  In case of accidental ignition, douse keyboard with water.
  32.