From 6d45dd837f896cf33fbf5d723cb56f89ecf0142e Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Sun, 12 Jul 2020 19:11:19 -0500 Subject: [PATCH] Remove trailing ", " in `functions` output When executed interactively and not piped, `functions` adds a comma as a separator between each result. This removes the separator after the last item. --- src/builtin_functions.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/builtin_functions.cpp b/src/builtin_functions.cpp index f0fb7bca2..f40ada015 100644 --- a/src/builtin_functions.cpp +++ b/src/builtin_functions.cpp @@ -372,6 +372,11 @@ int builtin_functions(parser_t &parser, io_streams_t &streams, wchar_t **argv) { buff.append(name); buff.append(L", "); } + if (names.size() > 0) { + // Trim trailing ", " + buff.resize(buff.size() - 2, '\0'); + } + streams.out.append(reformat_for_screen(buff, termsize_last())); } else { for (const auto &name : names) {