pushd within a pipeline says it's adding to the stack, but it's not?
0
votes
0
answers
50
views
I'm working on a modification of [this approach](https://superuser.com/a/608622) to automatically saving and restoring bash's directory stack state when using
pushd
and popd
.
For some reason, my code to restore the saved state isn't working -- I'm calling pushd
on the right entries, and it says it's pushing those onto the stack, but afterwards, dirs -v
is unchanged!
I have some directories, one per line, in a file, and I'm using this to recreate the stack:
tac $BASH_DIR_STACK_FILE | sort | uniq | while read -r dir
do
echo $dir
pushd -n "$dir" > /dev/null
done
When I run that, it works as expected, and claims to be pushing each of the directories. But afterwards, when I do dirs -v
, there's no change to the stack!
Using pushd
manually for the same directories works as expected.
I also tried the declare
approach with $DIRSTACK
from [this post](https://unix.stackexchange.com/a/366852/632891) but that doesn't work either.
Why isn't my directory stack getting updated via pushd
inside that loop?
Asked by Dan Drake
(151 rep)
Aug 3, 2024, 01:51 PM
Last activity: Aug 3, 2024, 04:43 PM
Last activity: Aug 3, 2024, 04:43 PM