mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-23 13:24:01 +08:00
function: Don't list empty function names and directories
This commit is contained in:
parent
daf5e11179
commit
8d7662335e
|
@ -127,12 +127,16 @@ 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)) {
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void function_add(wcstring name, std::shared_ptr<function_properties_t> props) {
|
||||
|
|
|
@ -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 New Issue
Block a user