Always use "." for cd

Nobody doesn't want to use $PWD to cd, so if $CDPATH does not include
it that was a mistake.

Bash also appends "." here.

Fixes #4484.
This commit is contained in:
Fabian Homborg
2019-03-26 10:11:36 +01:00
parent eeec6cc2fc
commit b86200938f
6 changed files with 23 additions and 4 deletions

View File

@@ -173,9 +173,8 @@ maybe_t<wcstring> path_get_cdpath(const wcstring &dir, const wcstring &wd,
if (auto cdpaths = env_vars.get(L"CDPATH")) {
cdpathsv = cdpaths->as_list();
}
if (cdpathsv.empty()) {
cdpathsv.push_back(L".");
}
// Always append $PWD
cdpathsv.push_back(L".");
for (wcstring next_path : cdpathsv) {
if (next_path.empty()) next_path = L".";
if (next_path == L"." && !wd.empty()) {