From b521ca4875260ebf39e610dc4ad7a513819a2f17 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Wed, 2 Sep 2020 17:48:24 +0200 Subject: [PATCH] Always check for fish_right_prompt's existence This would only check for fish_right_prompt at startup, so if one wasn't defined then it would never accept one. The "config" here is just the *name* of the function (which we never change, so it wouldn't really be necessary, but whatever). The one exception is the breakpoint, in those we don't run the right prompt. Fixes #7302. --- src/reader.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/reader.cpp b/src/reader.cpp index 8ed590f34..d5856f8e5 100644 --- a/src/reader.cpp +++ b/src/reader.cpp @@ -1205,12 +1205,14 @@ void reader_data_t::exec_prompt() { } if (!conf.right_prompt_cmd.empty()) { - // Status is ignored. - wcstring_list_t prompt_list; - exec_subshell(conf.right_prompt_cmd, parser(), prompt_list, false); - // Right prompt does not support multiple lines, so just concatenate all of them. - for (const auto &i : prompt_list) { - right_prompt_buff += i; + if (function_exists(conf.right_prompt_cmd, parser())) { + // Status is ignored. + wcstring_list_t prompt_list; + exec_subshell(conf.right_prompt_cmd, parser(), prompt_list, false); + // Right prompt does not support multiple lines, so just concatenate all of them. + for (const auto &i : prompt_list) { + right_prompt_buff += i; + } } } } @@ -2510,15 +2512,12 @@ static int read_i(parser_t &parser) { if (parser.libdata().is_breakpoint && function_exists(DEBUG_PROMPT_FUNCTION_NAME, parser)) { conf.left_prompt_cmd = DEBUG_PROMPT_FUNCTION_NAME; + conf.right_prompt_cmd = wcstring{}; } else { conf.left_prompt_cmd = LEFT_PROMPT_FUNCTION_NAME; + conf.right_prompt_cmd = RIGHT_PROMPT_FUNCTION_NAME; } - if (function_exists(RIGHT_PROMPT_FUNCTION_NAME, parser)) { - conf.right_prompt_cmd = RIGHT_PROMPT_FUNCTION_NAME; - } else { - conf.right_prompt_cmd = wcstring{}; - } std::shared_ptr data = reader_push_ret(parser, history_session_id(parser.vars()), std::move(conf));