functions -q: Return false without an argument

This erroneously listed functions and returned true.
This commit is contained in:
Fabian Homborg 2019-02-01 18:29:54 +01:00
parent df375ea12d
commit ff89c61afa
4 changed files with 15 additions and 0 deletions

View file

@ -337,6 +337,11 @@ int builtin_functions(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
return STATUS_CMD_OK;
}
// If we query with no argument, just return false.
if (opts.query && argc == optind) {
return STATUS_CMD_ERROR;
}
if (opts.list || argc == optind) {
wcstring_list_t names = function_get_names(opts.show_hidden);
std::sort(names.begin(), names.end());

View file

@ -29,3 +29,6 @@ fish: function: The name 'test' is reserved,
and can not be used as a function name
function test; echo banana; end
^
####################
# Checking `functions -q` without arguments

View file

@ -58,4 +58,7 @@ test "$name3[2..-1]" = "$name3a[2..-1]"; and echo "3 = 3a"
logmsg Checking reserved names
function test; echo banana; end
logmsg Checking `functions -q` without arguments
functions -q; or echo "False"
exit 0

View file

@ -71,3 +71,7 @@ function name3a --argument arg1 arg2
####################
# Checking reserved names
####################
# Checking `functions -q` without arguments
False