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