How is the pushd directory stack stored?

jallersma

In a related question somebody states that the directory stack of the pushd command is emptied when your shell terminates. But how is the stack actually stored? I use fish instead of bash and the commands work the same way. I would assume pushd (and popd) works independently of the shell you're using. Or do both shells have their own implementation?

Paul_Pedant

The directory stack is not stored anywhere permanent. Shell just keeps it in process memory, in an array DIRSTACK (which has restrictions on user modification). It's not even strictly a stack -- bash and ksh allow you to rotate it left and right by specified counts, too.

In Bash, the dirs command clears or shows the stack in various ways, popd removes any specified dir, and pushd adds a dir or rotates the stack to change to any of the dirs already stored.

The pushd stack is not "cleared" as such. Pushd is a shell built-in, not an external command (which would not be able to change the shell's own environment). Each shell retains its own pushd data, and when that shell process goes away, the contents are just discarded.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Making 'pushd' directory stack persistent

From Dev

In powershell, is there a way to copy to last directory on `pushd`'d stack?

From Dev

How can I view the stack used by `pushd` and `popd`?

From Dev

How can I loop over my pushd stack?

From Dev

How are arrays stored on the stack?

From Dev

how variables are stored on stack?

From Dev

How are arrays stored on the stack?

From Dev

how variables are stored on stack?

From Dev

How many calls will be stored in stack?

From Dev

How many calls will be stored in stack?

From Dev

How does pushd work?

From Dev

How to use PUSHD and POPD

From Dev

removing or clearing stack of popd/pushd paths

From Dev

Why does `pushd` always output the stack to stdout?

From Dev

How do local variables get stored in stack?

From Java

Don't display pushd/popd stack across several bash scripts (quiet pushd/popd)

From Dev

How to reference image stored in directory in MySQL table?

From Dev

How are directory structures stored in UNIX filesystem?

From Dev

How to recursively find the amount stored in directory?

From Dev

how to view images stored in application directory in gallery

From Dev

How to mount a directory in virtualbox with Salt-Stack?

From Dev

How to pushd mutliple folders on Windows batch

From Dev

How do I use pushd and popd commands?

From Dev

How to demonstrate where a c# variable is stored, stack or heap

From Dev

Javascript string stored on stack

From Dev

Pointer to a variable stored in the stack

From Dev

How do I loop through a directory path stored in a variable

From Dev

How do I call a stored procedure on each of the files in a directory as a parameter?

From Dev

How do I loop through a directory path stored in a variable

Related Related

HotTag

Archive