From 7fa454666d55264d6b8f78af302298694b21dee7 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Tue, 26 Mar 2019 19:29:44 +0100 Subject: [PATCH] Only append newline if stacktrace isn't empty This printed weird things like ```fish $ functions -x functions: Unknown option '-x' (Type 'help functions' for related documentation) ``` Instead, let's make it ```fish $ functions -x functions: Unknown option '-x' (Type 'help functions' for related documentation) ``` --- src/builtin.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/builtin.cpp b/src/builtin.cpp index f30162799..347f5c216 100644 --- a/src/builtin.cpp +++ b/src/builtin.cpp @@ -207,8 +207,12 @@ void builtin_missing_argument(parser_t &parser, io_streams_t &streams, const wch /// Print the backtrace and call for help that we use at the end of error messages. void builtin_print_error_trailer(parser_t &parser, output_stream_t &b, const wchar_t *cmd) { b.append(L"\n"); - b.append(parser.current_line()); - b.append(L"\n"); + const wcstring stacktrace = parser.current_line(); + // Don't print two empty lines if we don't have a stacktrace. + if (!stacktrace.empty()) { + b.append(stacktrace); + b.append(L"\n"); + } b.append_format(_(L"(Type 'help %ls' for related documentation)\n"), cmd); }