home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / unix / question / 10257 < prev    next >
Encoding:
Text File  |  1992-08-21  |  1.1 KB  |  39 lines

  1. Newsgroups: comp.unix.questions
  2. Path: sparky!uunet!news.encore.com!mpalmer
  3. From: mpalmer@encore.com (Mike Palmer)
  4. Subject: csh equivalent of ksh function?
  5. Sender: news@encore.com (Usenet readnews user id)
  6. Message-ID: <BtC1LI.o3@encore.com>
  7. Date: Fri, 21 Aug 1992 12:05:41 GMT
  8. Nntp-Posting-Host: sysgem1.encore.com
  9. Organization: Encore Computer Corporation
  10. Lines: 27
  11.  
  12. Thanks to all those who answered my "how to cd & stay" question.  I ended up
  13. using a ksh function, but I'd like it to work in csh too.
  14.  
  15. I have the following ksh function that allows the "sdx" program to select 
  16. a directory to change to and write the name in the home directory file:
  17. _t_e_m_p_. The function then does a cd to that directory.  (This is the basis
  18. of an smart directory changer.)
  19.  
  20. sd()
  21. {
  22.   sdx $@
  23.   if test -f ${HOME}/_t_e_m_p_
  24.   then
  25.     cd `cat ${HOME}/_t_e_m_p_`
  26.     rm ${HOME}/_t_e_m_p_
  27.   fi
  28. }
  29.  
  30. The simpler form "cd `sdx $@`" suggested by most, won't work because sdx
  31. sometimes asks the user which directory he want's to move to. 
  32.  
  33. What would be the best way to do this in csh? 
  34.  
  35. Regards,
  36. Mike palmer
  37. Telephone: (305) 797-2326 (W)   (305) 7546-3146 (H)
  38.  
  39.