Commit | Line | Data |
---|---|---|
d1b73048 KB |
1 | # Copyright (c) 1991, 1993 |
2 | # The Regents of the University of California. All rights reserved. | |
11d9372d KB |
3 | # |
4 | # This code is derived from software contributed to Berkeley by | |
5 | # Kenneth Almquist. | |
6 | # | |
7 | # %sccs.include.redist.sh% | |
8 | # | |
d1b73048 | 9 | # @(#)dirs 8.1 (Berkeley) %G% |
11d9372d KB |
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 | ||
15 | pushd () { | |
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 | ||
32 | popd () { | |
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 | ||
44 | dirs () { | |
45 | echo "`pwd` $DSTACK" | |
46 | return 0 | |
47 | } |