home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / unix / programm / 4039 < prev    next >
Encoding:
Internet Message Format  |  1992-07-31  |  1.3 KB

  1. Path: sparky!uunet!gatech!rutgers!cmcl2!prism.poly.edu!kapela
  2. From: kapela@prism.poly.edu (Theodore S. Kapela)
  3. Newsgroups: comp.unix.programmer
  4. Subject: Re: expanding ~'s in a directory name.
  5. Message-ID: <1992Jul31.151135.25775@prism.poly.edu>
  6. Date: 31 Jul 92 15:11:35 GMT
  7. References: <1992Jul29.012629.14000@gucis.cit.gu.edu.au> <MJN.92Jul31043705@pseudo.uucp>
  8. Organization: Polytechnic University, New York
  9. Lines: 27
  10.  
  11. In article <MJN.92Jul31043705@pseudo.uucp> mjn@pseudo.uucp (Murray Nesbitt) writes:
  12. >
  13. >In article <1992Jul29.012629.14000@gucis.cit.gu.edu.au> aroll@gucis.cit.gu.edu.au (Ashley Roll) writes:
  14. >
  15. >>My problem is how do I expand ~'s. I want to expand then the way that csh does
  16. >
  17. >
  18. >I don't care^H^H^H^Hknow about the csh, but the following should work
  19. >with sh and ksh:
  20. >
  21. >#include <stdlib.h>
  22. >
  23. >char *expanded_tilde;
  24. >
  25. >    expanded_tilde = getenv("HOME");
  26. >
  27.  
  28. What about ~user instead of just ~?  With csh, I can do something
  29. like cd ~joeuser/tmp to cd to joeuser's $HOME/tmp.  What your function
  30. needs to do is check what follows the ~ and act appropriately.  You still
  31. need to check /etc/passwd for other users.
  32.  
  33. -- 
  34. ..............................................................................
  35.  Theodore S. Kapela                kapela@poly.edu
  36.  Center for Applied Large-Scale Computing    
  37.  Polytechnic University
  38.