dirs revision 50471
150276Speter# Copyright (c) 1991, 1993
2176187Srafan#	The Regents of the University of California.  All rights reserved.
350276Speter#
450276Speter# This code is derived from software contributed to Berkeley by
550276Speter# Kenneth Almquist.
650276Speter#
750276Speter# Redistribution and use in source and binary forms, with or without
850276Speter# modification, are permitted provided that the following conditions
950276Speter# are met:
1050276Speter# 1. Redistributions of source code must retain the above copyright
1150276Speter#    notice, this list of conditions and the following disclaimer.
1250276Speter# 2. Redistributions in binary form must reproduce the above copyright
1350276Speter#    notice, this list of conditions and the following disclaimer in the
1450276Speter#    documentation and/or other materials provided with the distribution.
1550276Speter# 3. All advertising materials mentioning features or use of this software
1650276Speter#    must display the following acknowledgement:
1750276Speter#	This product includes software developed by the University of
1850276Speter#	California, Berkeley and its contributors.
1950276Speter# 4. Neither the name of the University nor the names of its contributors
2050276Speter#    may be used to endorse or promote products derived from this software
2150276Speter#    without specific prior written permission.
2250276Speter#
2350276Speter# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2450276Speter# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2550276Speter# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2650276Speter# ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2750276Speter# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2850276Speter# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2950276Speter# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3050276Speter# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3150276Speter# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32166124Srafan# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3350276Speter# SUCH DAMAGE.
3450276Speter#
3550276Speter#	@(#)dirs	8.2 (Berkeley) 5/4/95
3650276Speter# $FreeBSD: head/bin/sh/funcs/dirs 50471 1999-08-27 23:15:48Z peter $
37184989Srafan
3850276Speter# pushd, popd, and dirs --- written by Chris Bertin
3950276Speter# Pixel Computer Inc. ...!wjh12!pixel!pixutl!chris
4050276Speter# as modified by Patrick Elam of GTRI and Kenneth Almquist at UW
4150276Speter
4250276Speterpushd () {
4350276Speter	SAVE=`pwd`
4450276Speter	if [ "$1" = "" ] 
4550276Speter	then	if [ "$DSTACK" = "" ]
4650276Speter		then	echo "pushd: directory stack empty."
4750276Speter			return 1
4850276Speter		fi
4976726Speter		set $DSTACK
5076726Speter		cd $1 || return
5150276Speter		shift 1
5250276Speter		DSTACK="$*"
5350276Speter	else	cd $1 > /dev/null || return
5450276Speter	fi
5550276Speter	DSTACK="$SAVE $DSTACK"
5650276Speter	dirs
5750276Speter}
5850276Speter
5950276Speterpopd () {
6050276Speter	if [ "$DSTACK" = "" ] 
6150276Speter	then	echo "popd: directory stack empty."
6250276Speter		return 1
6350276Speter	fi
6450276Speter	set $DSTACK
6550276Speter	cd $1
6650276Speter	shift
6750276Speter	DSTACK=$*
6850276Speter	dirs
6950276Speter}
7050276Speter
7150276Speterdirs () {
7250276Speter	echo "`pwd` $DSTACK"
7350276Speter	return 0
7450276Speter}
7550276Speter