News for hackers. Stuff that matters.
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"`
Re:Shell Script Best Practices, from a decade of scripting t... by karl42 on Thursday October 27, 2022 @12:06PM (#33359656)
I fully agree. The parent wrote "before changing directory", so I assumed we are talking about the case where changing directory was necessary.