ksh emulation of dirs, pushd, and popd of csh

Scott Telford scott at cs.hw.ac.uk
Sun Feb 24 05:26:51 AEST 1991

In article <1947 at seti.inria.fr> gh at 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.
#pushd/popd/dirs for Bourne Shell with shell functions
#Scott Telford, Dept of Comp Sci, Heriot-Watt Uni, 24-10-90


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 at cs.hw.ac.uk    |
| Heriot-Watt University, Edinburgh, UK.                 scott%hwcs at ukc.uucp  |
|_____ "Expect the unexpected." (The Hitch-Hiker's Guide to the Galaxy) ______|

More information about the Alt.sources mailing list