Skip to main content
edited tags
Link
Jeff Schaller
  • 68.9k
  • 35
  • 122
  • 268
Source Link
ahmet alp balkan
  • 741
  • 1
  • 11
  • 25

Difference between pushd/popd and sub-shell+cd

I'm trying to understand if there are any benefits of using:

pushd my_dir make all # ... or something else popd 

vs

( cd my_dir make all # ... or something else ) 

or is it merely a preference thing?

I guess the latter notation can have issues like you may need to set -e (and other flags again), but it still carries out the exit code of its last command, and looks better in terms of syntax.