Re: How to create my own "pushd" command?



www <xsli2@xxxxxxxxx> wrote:
For reasons I am unclear, our institute use ksh.

dirs() { for _P in "${PWDS[@]}" "$PWD"; do echo "$_P"; done | tac | xargs; }
pushd() { PWDS+=("$PWD"); cd "$1"; dirs; }
popd() { _P="${PWDS[@]: -1:1}"; unset PWDS[$((${#PWDS[@]} -1))]; cd "$_P"; dirs; }

Chris
.