Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!lll-winken!csustan!csun!abcscnuk From: abcscnuk@csun.UUCP (Naoto Kimura) Newsgroups: comp.unix.questions Subject: Re: ksh questions Message-ID: <802@csun.UUCP> Date: Fri, 9-Oct-87 19:04:45 EDT Article-I.D.: csun.802 Posted: Fri Oct 9 19:04:45 1987 Date-Received: Mon, 12-Oct-87 19:38:22 EDT References: <692@hsi.UUCP> <10342@duke.cs.duke.edu> <15249@topaz.rutgers.edu> Reply-To: abcscnuk@csun.UUCP (Naoto Kimura) Organization: California State University, Northridge Lines: 88 Keywords: yapushd, yapopd In article <15249@topaz.rutgers.edu> ron@topaz.rutgers.edu (Ron Natalie) writes: >Here's a couple I wrote for the 5R2 Bourne Shell: >I don't set the prompt to the directory names because I find it >disgusting, but you can do that by doing PS1="$DIRSTACK" in both >popd and pushd. > I thought I might post mine too. //-n-\\ Naoto Kimura _____---=======---_____ (csun!abcscnuk) ====____\ /.. ..\ /____==== // ---\__O__/--- \\ Enterprise... Surrender or we'll \_\ /_/ send back your *&^$% tribbles !! ----------------------------------------------------------------- DIRSTAK="" dirs() { echo `pwd` $DIRSTAK } listhead() { echo $1 } listtail() { shift echo $* } pushdir() { if test $# -eq 0 then if test "$DIRSTAK" = "" then echo "directory stack empty." >&2 return 1 else OLDPWD=`pwd` popdir DIRSTAK="$OLDPWD $DIRSTAK" fi else while test "$*" != "" do OLDPWD=`pwd` if cd "$1" then DIRSTAK="$OLDPWD $DIRSTAK" fi shift done fi } popdir() { if test $# -ne 0 then echo "No parameters allowed with popdir" >&2 return 1 else if test "$DIRSTAK" = "" then echo "directory stack empty." >&2 return 1 else TMP1=`listhead $DIRSTAK` DIRSTAK=`listtail $DIRSTAK` if test "$TMP1" != "" then cd "$TMP1" fi fi fi } pushd() { if pushdir $* then dirs fi } popd() { if popdir $* then dirs fi }