From 7da93e26176f9996a0d49cc7da2a8151c8550a36 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sun, 29 Nov 2020 06:20:43 +0100 Subject: [PATCH] builtin functions: don't mix up multiple arguments This regressed in 2e38cf2a which is contained in 2.6.0. Fixes #7515 --- src/builtin_functions.cpp | 2 +- tests/checks/functions.fish | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/builtin_functions.cpp b/src/builtin_functions.cpp index 23cf62ea2..e527e100c 100644 --- a/src/builtin_functions.cpp +++ b/src/builtin_functions.cpp @@ -329,7 +329,7 @@ maybe_t builtin_functions(parser_t &parser, io_streams_t &streams, wchar_t } else { if (!opts.query) { if (i != optind) streams.out.append(L"\n"); - const wchar_t *funcname = argv[optind]; + const wchar_t *funcname = argv[i]; report_function_metadata(funcname, opts.verbose, streams, parser, true); wcstring def = functions_def(funcname); diff --git a/tests/checks/functions.fish b/tests/checks/functions.fish index 313f8a482..ac22363dd 100644 --- a/tests/checks/functions.fish +++ b/tests/checks/functions.fish @@ -73,6 +73,16 @@ functions -d description2 test_func_desc functions test_func_desc | string match --quiet '*description2*' or echo "Failed to find description 2" >&2 +# ========== +# Verify that the functions are printed in order. +functions f1 test_func_desc +# CHECK: # Defined in {{.*}} +# CHECK: function f1 +# CHECK: end +# CHECK: # Defined in {{.*}} +# CHECK: function test_func_desc --description description2 +# CHECK: end + # Note: This test isn't ideal - if ls was loaded before, # or doesn't exist, it'll succeed anyway. #