Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site pixutl.UUCP Path: utzoo!linus!decvax!wivax!cadmus!harvard!wjh12!pixel!pixutl!chris From: chris@pixutl.UUCP (chris) Newsgroups: net.unix Subject: another pushd/popd for sh Message-ID: <62@pixutl.UUCP> Date: Fri, 2-Nov-84 12:14:44 EST Article-I.D.: pixutl.62 Posted: Fri Nov 2 12:14:44 1984 Date-Received: Sun, 4-Nov-84 04:49:07 EST Organization: Pixel Computer Inc., Wilmington, Mass. Lines: 58 I have seen several pushd/popd for the shell, lately, but they don't behave like the Cshell's. This one looks to the user like the 4.1 version (it doesn't have the '+n' option). ---------- DSTACK='' pushd(){ SAVE=`pwd` DSTACK="$SAVE $DSTACK" if [ "$1" = "" ] ; then if [ "$DSTACK" = "$SAVE " ] ; then echo "pushd: No other directory" DSTACK="" return 1 fi set $DSTACK cd $2 shift shift DSTACK="$SAVE $*" else if (cd $1) ; then cd $1 >&- else popd > /dev/null return 1 fi fi dirs return 0 } popd(){ if [ "$DSTACK" = "" ] ; then echo "popd: Directory stack empty" return 1 fi set $DSTACK cd $1 shift DSTACK=$* dirs return 0 } dirs(){ echo "`pwd` $DSTACK" return 0 } -- Chris Bertin : (617) 657-8720 x2318 Pixel Computer Inc. : 260 Fordham Rd. : {allegra|ihnp4|cbosgd|ima|genrad|amd|harvard}\ Wilmington, Ma 01887 : !wjh12!pixel!pixutl!chris