home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 2 / 2854 < prev    next >
Encoding:
Internet Message Format  |  1991-02-25  |  1.6 KB

  1. From: scott@cs.hw.ac.uk (Scott Telford)
  2. Newsgroups: alt.sources
  3. Subject: Re: ksh emulation of dirs, pushd, and popd of csh
  4. Message-ID: <2374@odin.cs.hw.ac.uk>
  5. Date: 23 Feb 91 18:26:51 GMT
  6.  
  7.  
  8. In article <1947@seti.inria.fr> gh@bdblues.altair.fr (gilbert harrus) writes:
  9. >I just moved from [t]csh to ksh, and I wrote this "package" to learn more
  10. >about ksh.
  11. >
  12. >Save in a file, say dirs.ksh, and type : eval . dirs.ksh
  13. >Not extensively tested...
  14. >
  15.  
  16. I did the same thing a while ago for Bourne Shell, basically because I
  17. use tcsh all the time on Unix systems, but the best Unix-style shell for
  18. DOS I've found is the Data Logic MS-DOS sh.
  19.  
  20. As you can see, mine is a bit more compact than Gilbert's 8^)...
  21. It doesn't support the '+n' switch but it's just about as minimalist
  22. as you can get.
  23.  
  24. Note that older Bourne Shells don't have shell functions.
  25.  
  26. Share and enjoy.
  27. -------------------------------------------------------------------------------
  28. #!bin/sh
  29. #pushd/popd/dirs for Bourne Shell with shell functions
  30. #Scott Telford, Dept of Comp Sci, Heriot-Watt Uni, 24-10-90
  31.  
  32. DIRSTACK=$HOME
  33.  
  34. dirs() { echo $DIRSTACK ; }
  35.  
  36. popd() { set - $DIRSTACK  && shift  && cd $1  && DIRSTACK=$@  && dirs ; }
  37.  
  38. pushd() { cd $1  && DIRSTACK=`pwd`" "$DIRSTACK  && dirs ; }
  39.  
  40. -------------------------------------------------------------------------------
  41.  _____________________________________________________________________________
  42. | Scott Telford, Dept of Computer Science,               scott@cs.hw.ac.uk    |
  43. | Heriot-Watt University, Edinburgh, UK.                 scott%hwcs@ukc.uucp  |
  44. |_____ "Expect the unexpected." (The Hitch-Hiker's Guide to the Galaxy) ______|
  45.