Web lists-archives.com

Re: pushd/popd




On Sat 10 Nov 2018 at 09:47:37 (-0800), peter@xxxxxxxxxxx wrote:
> *	From: peter@xxxxxxxxxxx
> *	Date: Fri, 09 Nov 2018 06:20:01 -0800
> > Why?  Easy enough to use pushd/popd and easy enough to not [use] it but 
> > I'm interested in the reasoning behind this choice.
> 
> I've read the arguments but no answer to my question.
> Is there an intrinsic reason to avoid pushd/popd?  Not 
> in POSIX merely because it isn't done yet?

Oversimplifying somewhat…

Pushd/popd are really designed for interactive use rather than for
scripts. Hence they remind you of the stack's contents when you use them.

Dash is designed to be small and fast so that it can run scripts faster.
It doesn't need bloating with pushd/popd.

BTW whenever I change directory in scripts, I make sure that I'm in a
subshell by using ( and ), which guarantees that I get back to the
same directory however the script finishes.

Cheers,
David.