# ( cd dir ) must restore the working directory and PWD. dir=$PWD ( cd / ) test "$PWD" = "$dir" || { echo "PWD not restored"; exit 1; } test "$(pwd)" = "$dir" || { echo "cwd not restored"; exit 1; } echo ok