Revert "wildcard: Remove useless access() call for trailing slash"

This reverts commit 6823f5e337.

Fixes #10205
This commit is contained in:
Fabian Boehm 2024-01-09 18:56:36 +01:00
parent 001f797f80
commit c31e194120
2 changed files with 9 additions and 2 deletions

View file

@ -646,8 +646,11 @@ void wildcard_expander_t::expand_trailing_slash(const wcstring &base_dir, const
}
if (!(flags & expand_flag::for_completions)) {
// Trailing slash and not accepting incomplete, e.g. `echo /xyz/`. Insert this file, we already know it exists!
this->add_expansion_result(wcstring{base_dir});
// Trailing slash and not accepting incomplete, e.g. `echo /xyz/`. Insert this file if it
// exists.
if (waccess(base_dir, F_OK) == 0) {
this->add_expansion_result(wcstring{base_dir});
}
} else {
// Trailing slashes and accepting incomplete, e.g. `echo /xyz/<tab>`. Everything is added.
dir_iter_t dir = open_dir(base_dir);

View file

@ -11,6 +11,10 @@ touch ./b/file.txt
set dirs ./a ./b
echo $dirs/*.txt # CHECK: ./b/file.txt
echo */foo/
# CHECKERR: checks/wildcard.fish (line {{\d+}}): No matches for wildcard '*/foo/'. See `help wildcards-globbing`.
# CHECKERR: echo */foo/
# CHECKERR: ^~~~~^
cd $oldpwd
rm -Rf $dir