Skip to content

Commit 6f1eba6

Browse files
jmouscop
authored andcommitted
fix(cd): Complete from . on empty CDPATH entry (#1527)
1 parent 5b5b9cc commit 6f1eba6

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

completions-core/cd.bash

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ _comp_cmd_cd__compgen_cdpath()
3838
local paths dirs _d
3939
_comp_split -F : paths "$CDPATH"
4040
for _p in "${paths[@]}"; do
41+
_p="${_p:-.}"
4142
# create an array of matched subdirs
4243
_comp_compgen -v dirs -c "$_p/$cur" -- -d &&
4344
for _d in "${dirs[@]}"; do

test/t/test_cd.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,15 @@ def test_cdable_vars_2(self, bash):
5151
bash_env.write_variable("foo2", "shared/default")
5252
completion = assert_complete(bash, "cd f")
5353
assert completion == ["foo1", "foo2"]
54+
55+
@pytest.mark.complete("cd ", cwd="shared/default", env=dict(CDPATH=":.."))
56+
def test_cdpath_leading_colon(self, completion):
57+
assert completion == [
58+
".ssh/",
59+
"bar bar.d/",
60+
"bin/",
61+
"default/",
62+
"empty_dir/",
63+
"foo.d/",
64+
"ld.so.conf.d/",
65+
]

0 commit comments

Comments
 (0)