Hacker News new | ask | show | jobs
by chriswarbo 1329 days ago
pushd and popd are commands which change the current working directory. In contrast, variables like $PWD are expressions, which are far more flexible. For example, we can run commands like `diff "$OLD_PWD/foo" "$PWD/bar"` which reference multiple directories. Doing that with pushd/popd would be weird, e.g. `diff "$(popd; echo "$PWD/foo")" "$PWD/bar"`
1 comments

I fully agree. The parent wrote "before changing directory", so I assumed we are talking about the case where changing directory was necessary.