date and time created 91/03/07 20:27:30 by bostic
[unix-history] / usr / src / bin / sh / funcs / dirs
CommitLineData
11d9372d
KB
1# Copyright (c) 1991 The Regents of the University of California.
2# All rights reserved.
3#
4# This code is derived from software contributed to Berkeley by
5# Kenneth Almquist.
6#
7# %sccs.include.redist.sh%
8#
9# @(#)dirs 5.1 (Berkeley) %G%
10
11# pushd, popd, and dirs --- written by Chris Bertin
12# Pixel Computer Inc. ...!wjh12!pixel!pixutl!chris
13# as modified by Patrick Elam of GTRI and Kenneth Almquist at UW
14
15pushd () {
16 SAVE=`pwd`
17 if [ "$1" = "" ]
18 then if [ "$DSTACK" = "" ]
19 then echo "pushd: directory stack empty."
20 return 1
21 fi
22 set $DSTACK
23 cd $1 || return
24 shift 1
25 DSTACK="$*"
26 else cd $1 > /dev/null || return
27 fi
28 DSTACK="$SAVE $DSTACK"
29 dirs
30}
31
32popd () {
33 if [ "$DSTACK" = "" ]
34 then echo "popd: directory stack empty."
35 return 1
36 fi
37 set $DSTACK
38 cd $1
39 shift
40 DSTACK=$*
41 dirs
42}
43
44dirs () {
45 echo "`pwd` $DSTACK"
46 return 0
47}