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.
This commit is contained in:
Mahmoud Al-Qudsi
2020-07-12 19:11:19 -05:00
parent f1951fed3a
commit 6d45dd837f

View File

@@ -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) {