dirs revision 1556
11556Srgrimes# Copyright (c) 1991, 1993 21556Srgrimes# The Regents of the University of California. All rights reserved. 31556Srgrimes# 41556Srgrimes# This code is derived from software contributed to Berkeley by 51556Srgrimes# Kenneth Almquist. 61556Srgrimes# 71556Srgrimes# Redistribution and use in source and binary forms, with or without 81556Srgrimes# modification, are permitted provided that the following conditions 91556Srgrimes# are met: 101556Srgrimes# 1. Redistributions of source code must retain the above copyright 111556Srgrimes# notice, this list of conditions and the following disclaimer. 121556Srgrimes# 2. Redistributions in binary form must reproduce the above copyright 131556Srgrimes# notice, this list of conditions and the following disclaimer in the 141556Srgrimes# documentation and/or other materials provided with the distribution. 151556Srgrimes# 3. All advertising materials mentioning features or use of this software 161556Srgrimes# must display the following acknowledgement: 171556Srgrimes# This product includes software developed by the University of 181556Srgrimes# California, Berkeley and its contributors. 191556Srgrimes# 4. Neither the name of the University nor the names of its contributors 201556Srgrimes# may be used to endorse or promote products derived from this software 211556Srgrimes# without specific prior written permission. 221556Srgrimes# 231556Srgrimes# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 241556Srgrimes# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 251556Srgrimes# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 261556Srgrimes# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 271556Srgrimes# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 281556Srgrimes# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 291556Srgrimes# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 301556Srgrimes# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 311556Srgrimes# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 321556Srgrimes# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 331556Srgrimes# SUCH DAMAGE. 341556Srgrimes# 351556Srgrimes# @(#)dirs 8.1 (Berkeley) 5/31/93 361556Srgrimes 371556Srgrimes# pushd, popd, and dirs --- written by Chris Bertin 381556Srgrimes# Pixel Computer Inc. ...!wjh12!pixel!pixutl!chris 391556Srgrimes# as modified by Patrick Elam of GTRI and Kenneth Almquist at UW 401556Srgrimes 411556Srgrimespushd () { 421556Srgrimes SAVE=`pwd` 431556Srgrimes if [ "$1" = "" ] 441556Srgrimes then if [ "$DSTACK" = "" ] 451556Srgrimes then echo "pushd: directory stack empty." 461556Srgrimes return 1 471556Srgrimes fi 481556Srgrimes set $DSTACK 491556Srgrimes cd $1 || return 501556Srgrimes shift 1 511556Srgrimes DSTACK="$*" 521556Srgrimes else cd $1 > /dev/null || return 531556Srgrimes fi 541556Srgrimes DSTACK="$SAVE $DSTACK" 551556Srgrimes dirs 561556Srgrimes} 571556Srgrimes 581556Srgrimespopd () { 591556Srgrimes if [ "$DSTACK" = "" ] 601556Srgrimes then echo "popd: directory stack empty." 611556Srgrimes return 1 621556Srgrimes fi 631556Srgrimes set $DSTACK 641556Srgrimes cd $1 651556Srgrimes shift 661556Srgrimes DSTACK=$* 671556Srgrimes dirs 681556Srgrimes} 691556Srgrimes 701556Srgrimesdirs () { 711556Srgrimes echo "`pwd` $DSTACK" 721556Srgrimes return 0 731556Srgrimes} 74