date and time created 91/03/07 20:21:28 by bostic
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Fri, 8 Mar 1991 12:21:28 +0000 (04:21 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Fri, 8 Mar 1991 12:21:28 +0000 (04:21 -0800)
SCCS-vsn: bin/sh/funcs/dirs 5.1

usr/src/bin/sh/funcs/dirs [new file with mode: 0644]

diff --git a/usr/src/bin/sh/funcs/dirs b/usr/src/bin/sh/funcs/dirs
new file mode 100644 (file)
index 0000000..c92298a
--- /dev/null
@@ -0,0 +1,47 @@
+# Copyright (c) 1991 The Regents of the University of California.
+# All rights reserved.
+#
+# This code is derived from software contributed to Berkeley by
+# Kenneth Almquist.
+#
+# %sccs.include.redist.sh%
+#
+#      @(#)dirs        5.1 (Berkeley) %G%
+
+# pushd, popd, and dirs --- written by Chris Bertin
+# Pixel Computer Inc. ...!wjh12!pixel!pixutl!chris
+# as modified by Patrick Elam of GTRI and Kenneth Almquist at UW
+
+pushd () {
+       SAVE=`pwd`
+       if [ "$1" = "" ] 
+       then    if [ "$DSTACK" = "" ]
+               then    echo "pushd: directory stack empty."
+                       return 1
+               fi
+               set $DSTACK
+               cd $1 || return
+               shift 1
+               DSTACK="$*"
+       else    cd $1 > /dev/null || return
+       fi
+       DSTACK="$SAVE $DSTACK"
+       dirs
+}
+
+popd () {
+       if [ "$DSTACK" = "" ] 
+       then    echo "popd: directory stack empty."
+               return 1
+       fi
+       set $DSTACK
+       cd $1
+       shift
+       DSTACK=$*
+       dirs
+}
+
+dirs () {
+       echo "`pwd` $DSTACK"
+       return 0
+}