From 975023faf273243b1673d4267c94f75a60590849 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Tue, 26 Mar 2019 17:15:51 +0100 Subject: [PATCH] Print arguments on the same line as the function Now: ``` cd: Unknown option '-r' ~/dev/fish-shell/share/functions/cd.fish (line 40): builtin cd $argv ^ in function 'cd' with arguments '-r' in function 'f' in function 'd' in function 'b' with arguments '-1q --wurst' in function 'a' called on standard input ``` See #5434. --- src/parser.cpp | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/parser.cpp b/src/parser.cpp index ba0da627a..bbc1edf3a 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -379,7 +379,21 @@ void parser_t::stack_trace_internal(size_t block_idx, wcstring *buff) const { case FUNCTION_CALL: case FUNCTION_CALL_NO_SHADOW: { const function_block_t *fb = static_cast(b); - append_format(*buff, _(L"in function '%ls'\n"), fb->name.c_str()); + append_format(*buff, _(L"in function '%ls'"), fb->name.c_str()); + const process_t *const process = fb->process; + // Print arguments on the same line. + if (process->argv(1)) { + wcstring tmp; + + for (i = 1; process->argv(i); i++) { + if (i > 1) tmp.push_back(L' '); + tmp.append(process->argv(i)); + } + // TODO: Escape these. + append_format(*buff, _(L" with arguments '%ls'\n"), tmp.c_str()); + } else { + buff->append(L"\n"); + } break; } case SUBST: { @@ -402,19 +416,6 @@ void parser_t::stack_trace_internal(size_t block_idx, wcstring *buff) const { append_format(*buff, _(L"\tcalled on standard input\n")); } - if (b->type() == FUNCTION_CALL) { - const function_block_t *fb = static_cast(b); - const process_t *const process = fb->process; - if (process->argv(1)) { - wcstring tmp; - - for (i = 1; process->argv(i); i++) { - if (i > 1) tmp.push_back(L' '); - tmp.append(process->argv(i)); - } - append_format(*buff, _(L"\twith parameter list '%ls'\n"), tmp.c_str()); - } - } } // Recursively print the next block.