mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 13:23:09 +00:00
function: Don't list empty function names and directories
This commit is contained in:
parent
daf5e11179
commit
8d7662335e
2 changed files with 41 additions and 3 deletions
|
@ -127,9 +127,13 @@ static void autoload_names(std::unordered_set<wcstring> &names, bool get_hidden)
|
|||
if (!get_hidden && fn[0] == L'_') continue;
|
||||
|
||||
suffix = std::wcsrchr(fn, L'.');
|
||||
if (suffix && (std::wcscmp(suffix, L".fish") == 0)) {
|
||||
wcstring name(fn, suffix - fn);
|
||||
names.insert(name);
|
||||
// We need a ".fish" *suffix*, it can't be the entire name.
|
||||
if (suffix && suffix != fn && (std::wcscmp(suffix, L".fish") == 0)) {
|
||||
// Also ignore directories.
|
||||
if (!entry->is_dir()) {
|
||||
wcstring name(fn, suffix - fn);
|
||||
names.insert(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,4 +114,38 @@ end
|
|||
|
||||
functions -q; or echo False
|
||||
#CHECK: False
|
||||
|
||||
# See that we don't count a file with an empty function name,
|
||||
# or directories
|
||||
set -l tmpdir (mktemp -d)
|
||||
touch $tmpdir/.fish
|
||||
mkdir $tmpdir/directory.fish
|
||||
touch $tmpdir/actual_function.fish
|
||||
|
||||
begin
|
||||
set -l fish_function_path $tmpdir
|
||||
functions
|
||||
end
|
||||
# CHECK: actual_function
|
||||
|
||||
# these are functions defined either in this file,
|
||||
# or eagerly in share/config.fish.
|
||||
# I don't know of a way to ignore just them.
|
||||
#
|
||||
# CHECK: bg
|
||||
# CHECK: disown
|
||||
# CHECK: fg
|
||||
# CHECK: fish_command_not_found
|
||||
# CHECK: fish_sigtrap_handler
|
||||
# CHECK: frob
|
||||
# CHECK: kill
|
||||
# CHECK: name1
|
||||
# CHECK: name1a
|
||||
# CHECK: name3
|
||||
# CHECK: name3a
|
||||
# CHECK: t
|
||||
# CHECK: wait
|
||||
|
||||
rm -r $tmpdir
|
||||
|
||||
exit 0
|
||||
|
|
Loading…
Reference in a new issue