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)
```
This commit is contained in:
Fabian Homborg 2019-03-26 19:29:44 +01:00
parent 88d2d54276
commit 7fa454666d

View file

@ -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);
}