5 ms·
Pushd / popd are not POSIX and some shells like ash/dash don't support them. I would avoid them unless you are targeting a specific shell you know supports them
by GuB-42 4y ago
Pushd / popd are not POSIX and some shells like ash/dash don't support them. I would avoid them unless you are targeting a specific shell you know supports them (ex: bash).
- harry8 4y ago"targeting" seems like an odd thing to say there. This is an interactive shell command. Does the shell you are using interactively support it seems like a more interesting concern? We don't have to be portable typing commands into a shell. :-) Never seen {push,pop}d in a shell script.
- GuB-42 4y agoGP was specifically talking about scripts, and I see the utility. As an interactive feature, I use the "autopushd" option in zsh, which make all "cd" behave like pushd, and you can also use "cd -n" where "n" is the number of levels you want to go up the stack (so "cd -" is equivalent to "cd -1")
- harry8 4y agooh wow. How did I not see that? Sorry!