There are some easy experiments you can run to find the answers to your questions. Sometimes the best way to learn learn new tools is to play around with them.
If I poorly write a script that uses pushd /etc but I don't finish it with popd: Will /etc still be in the pushd+popd directory stack/in RAM after the Bash script has finished executing and Bash has terminated?
$ cd /tmp
$ echo 'pushd /etc' > experiment.sh
$ bash experiment.sh
experiment.sh is the poorly-written script. It uses
pushd to push the current directory on the stack and switch to
/etc/ then terminates. After the script terminated, the running shell was still in
Also does the pushd+popd directory stack clear (like variables do) if I close the terminal emulator session (which should terminate the Bash shell process for that terminal emulator session) without manually clearing it with popd?
$ cd /tmp
$ pushd /etc
-- close terminal --
-- open new terminal --
Above in one shell we use
pushd to push the current directory on the directory stack, close the terminal, then open a new terminal. In the new terminal we see that the directory that was previously pushed is not on the stack.