mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-20 05:41:14 -03:00
cd first, ask questions later (#7586)
cd: Just try to cd without checking first Some filesystems are broken and error out on `stat(3)` of existing and cd-able directories. So we just try to `fchdir` and report errors later. Fixes #7577.
This commit is contained in:
15
src/path.cpp
15
src/path.cpp
@@ -126,11 +126,8 @@ wcstring_list_t path_get_paths(const wcstring &cmd, const environment_t &vars) {
|
||||
return paths;
|
||||
}
|
||||
|
||||
maybe_t<wcstring> path_get_cdpath(const wcstring &dir, const wcstring &wd,
|
||||
wcstring_list_t path_apply_cdpath(const wcstring &dir, const wcstring &wd,
|
||||
const environment_t &env_vars) {
|
||||
int err = ENOENT;
|
||||
if (dir.empty()) return none();
|
||||
assert(!wd.empty() && wd.back() == L'/');
|
||||
wcstring_list_t paths;
|
||||
if (dir.at(0) == L'/') {
|
||||
// Absolute path.
|
||||
@@ -170,6 +167,16 @@ maybe_t<wcstring> path_get_cdpath(const wcstring &dir, const wcstring &wd,
|
||||
}
|
||||
}
|
||||
|
||||
return paths;
|
||||
}
|
||||
|
||||
maybe_t<wcstring> path_get_cdpath(const wcstring &dir, const wcstring &wd,
|
||||
const environment_t &env_vars) {
|
||||
int err = ENOENT;
|
||||
if (dir.empty()) return none();
|
||||
assert(!wd.empty() && wd.back() == L'/');
|
||||
auto paths = path_apply_cdpath(dir, wd, env_vars);
|
||||
|
||||
for (const wcstring &dir : paths) {
|
||||
struct stat buf;
|
||||
if (wstat(dir, &buf) == 0) {
|
||||
|
||||
Reference in New Issue
Block a user