Re:Awesome but commonly unknown Linux Commands
by leviathan on Wednesday August 10, 2011 @07:47AM
(#2867763)
It's not just handy for scripts, I think it's imperative in scripts where you want to go in and out of a lot of directories.
if "bar" doesn't exist, your cd .. will throw you off your original directory, whereas
you'll be guaranteed that after "popd" you're back in the right place to start a new iteration.
[ Parent
| on HN ]
Re:Awesome but commonly unknown Linux Commands
by phaker on Wednesday August 10, 2011 @08:57AM
(#2867944)
You really, really should use 'set -e' which will exit if there are any errors. Otherwise if 'bar' doesn't exist, you'll 'do something' in a wrong directory and frobnicate something you didn't want frobnicated.