# A lone ( cd dir ) must put the shell back where it was. start=$(pwd -P) (cd /); echo "after=$? same=$([ "$(pwd -P)" = "$start" ] && echo yes || echo no)" (cd /; pwd) (cd / && pwd) (cd /nonexistent) 2>/dev/null; echo "bad=$([ $? -ne 0 ] && echo nonzero) same=$([ "$(pwd -P)" = "$start" ] && echo yes || echo no)" (cd /) 2>/dev/null; echo "redir=$? same=$([ "$(pwd -P)" = "$start" ] && echo yes || echo no)" old=$OLDPWD (cd /); echo "vars=$([ "$PWD" = "$start" ] && echo pwd) $([ "$OLDPWD" = "$old" ] && echo oldpwd)" (cd /; :); echo "list=$? same=$([ "$(pwd -P)" = "$start" ] && echo yes || echo no)" (cd /) || echo no (cd /) && echo yes ( typeset -i PWD; (cd /) 2>/dev/null; echo "int=$? same=$([ "$(pwd -P)" = "$start" ] && echo yes || echo no)" ) readonly PWD (cd /) 2>/dev/null; echo "ro=$? same=$([ "$(pwd -P)" = "$start" ] && echo yes || echo no)"