Re:Shell Script Best Practices, from a decade of scripting t...
by chriswarbo on Thursday October 27, 2022 @07:44AM
(#33356130)
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"`
[ Parent
| on HN ]