#!/bin/ksh DIRSTACK=${DIRSTACK#* } if [[ -n $DIRSTACK ]]; then cd ${DIRSTACK%% *} print "$PWD" else print "stack empty, still in $PWD." fi # end listing 4