From 7f31acbf9b677ffcecea917970146de5e57c2dbb Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Wed, 2 Feb 2022 10:42:30 -0800 Subject: [PATCH] Prevent fish_title output from triggering a bel fish outputs the result of fish_title inside an escape sequence, which happens to be terminated by \a (BEL). It may happen that the initial output is interrupted; fish then emits the closing BEL and that makes an annoying beep. Output the fish_title all at once, even if a signal is delivered (so we don't get "stuck inside" the sequence). This is related to #8628 in that it's a "torn escape sequence." --- src/reader.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/reader.cpp b/src/reader.cpp index 6bafe2878..98f892645 100644 --- a/src/reader.cpp +++ b/src/reader.cpp @@ -1293,11 +1293,13 @@ void reader_write_title(const wcstring &cmd, parser_t &parser, bool reset_cursor wcstring_list_t lst; (void)exec_subshell(fish_title_command, parser, lst, false /* ignore exit status */); if (!lst.empty()) { - std::fputws(L"\x1B]0;", stdout); + wcstring title_line = L"\x1B]0;"; for (const auto &i : lst) { - std::fputws(i.c_str(), stdout); + title_line += i; } - ignore_result(write(STDOUT_FILENO, "\a", 1)); + title_line += L"\a"; + std::string narrow = wcs2string(title_line); + ignore_result(write_loop(STDOUT_FILENO, narrow.data(), narrow.size())); } outputter_t::stdoutput().set_color(rgb_color_t::reset(), rgb_color_t::reset());