pushd separated from on_exit function