[alt.sources] ksh emulation of dirs, pushd, and popd of csh

scott@cs.hw.ac.uk (Scott Telford) (02/24/91)

In article <1947@seti.inria.fr> gh@bdblues.altair.fr (gilbert harrus) writes:
>I just moved from [t]csh to ksh, and I wrote this "package" to learn more
>about ksh.
>
>Save in a file, say dirs.ksh, and type : eval . dirs.ksh
>Not extensively tested...
>

I did the same thing a while ago for Bourne Shell, basically because I
use tcsh all the time on Unix systems, but the best Unix-style shell for
DOS I've found is the Data Logic MS-DOS sh.

As you can see, mine is a bit more compact than Gilbert's 8^)...
It doesn't support the '+n' switch but it's just about as minimalist
as you can get.

Note that older Bourne Shells don't have shell functions.

Share and enjoy.
-------------------------------------------------------------------------------
#!bin/sh
#pushd/popd/dirs for Bourne Shell with shell functions
#Scott Telford, Dept of Comp Sci, Heriot-Watt Uni, 24-10-90

DIRSTACK=$HOME

dirs() { echo $DIRSTACK ; }

popd() { set - $DIRSTACK  && shift  && cd $1  && DIRSTACK=$@  && dirs ; }

pushd() { cd $1  && DIRSTACK=`pwd`" "$DIRSTACK  && dirs ; }

-------------------------------------------------------------------------------
 _____________________________________________________________________________
| Scott Telford, Dept of Computer Science,               scott@cs.hw.ac.uk    |
| Heriot-Watt University, Edinburgh, UK.                 scott%hwcs@ukc.uucp  |
|_____ "Expect the unexpected." (The Hitch-Hiker's Guide to the Galaxy) ______|