🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.unix.shell
1 messages
1 total messages Started by Piercarlo Grandi Wed, 26 Sep 1990 15:47
Pushd, popd, dirs for stock SysV.3 Bourne shell
#81
Author: Piercarlo Grandi
Date: Wed, 26 Sep 1990 15:47
65 lines
1762 bytes
You wwill find appended a small shell script that defines under a stock
System V Bourne shell the pushd, popd, dirs commands of csh(1). They are
trivially adapted to the Korn shell. I have taken care to make them as
robust as possible.

-----------------------------cut here-------------------------------
DIRS=''

# We do a few contortions to ensure correct behaviour
# if directory pathnames contain spaces et similia.
# The things that substitute ~ for $HOME are commented
# out; you may want to comment them in.

cwd()
{
    pwd				# | sed 's|'"$HOME"'/|~/|'
}

chdir()
{
    cd "$1"			# cd `echo "$1" | sed 's|^~/|'"$HOME"'/|`
}

pushd()
{
    CWD="`pwd`"

    case "$1" in

    '')	case "$DIRS" in
	'') echo "directory stack empty"; return 1;;
	esac
	set $DIRS; eval cd "$1"; >/dev/null || return 1
	shift; DIRS="'$CWD' $@"; cwd;;

    *)	chdir "$1" || return 1
	DIRS="'$CWD' $DIRS";;

    esac
    return 0
}

popd()
{
    case "$DIRS" in
    '') echo "directory stack empty"; return 1;;
    esac
    set $DIRS; eval cd "$1"
    shift; DIRS="$*"; cwd
    return 0
}

dirs()
{
    CWD="`pwd`" || return 1
    eval echo "'$CWD' $DIRS"	# | sed 's|'"$HOME"'/|~/|g'
    return 0
}

---------------------------cut here as well----------------------------
--
Piercarlo "Peter" Grandi           | ARPA: pcg%uk.ac.aber.cs@nsfnet-relay.ac.uk
Dept of CS, UCW Aberystwyth        | UUCP: ...!mcsun!ukc!aber-cs!pcg
Penglais, Aberystwyth SY23 3BZ, UK | INET: pcg@cs.aber.ac.uk
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads