Possible to add non-existing directory with pushd -n
From:
Marcus Johansson
Subject:
Possible to add non-existing directory with pushd -n
Date:
Fri, 17 Jul 2026 05:12:08 +0000
Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -march=x86-64 -mtune=generic -O2 -pipe -fno-plt
-fexceptions -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security
-fstack-clash-protection -fcf-protection -fno-omit
-frame-pointer -mno-omit-leaf-frame-pointer -g
-ffile-prefix-map=/build/bash/src=/usr/src/debug/bash -flto=auto
-DDEFAULT_PATH_VALUE='/usr/local/sbin:/usr/local/bin:/usr/bin'
-DSTANDARD_UTILS_PATH='/usr/bin' -DSY
S_BASHRC='/etc/bash.bashrc' -DSYS_BASH_LOGOUT='/etc/bash.bash_logout'
-DNON_INTERACTIVE_LOGIN_SHELLS -std=gnu17
uname output: Linux bednaArch 7.1.3-arch2-1 #1 SMP PREEMPT_DYNAMIC Tue, 14 Jul
2026 23:03:30 +0000 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu
Bash Version: 5.3
Patch Level: 15
Release Status: release
Description:
I can add a non existing directory using pushd by doing following:
pushd -n dir
This will add the directory 'dir' at position 1 in the stack even though it
does not exist
This means if I try to remove the top directory with popd without argument I
get following error:
bash: popd: dir: No such file or directory
The non existing directory can be removed using popd +1 (or the location it is
in)
I apologize if this is intended behavior and I am supposed to be able to add
non-existing directories, therefore creating a false bug report.
Repeat-By:
$ pushd -n <non_existing_dir>