mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-02-21 09:12:11 +08:00
Fix crash with set_color --print-colors --background normal
Found in conjunction with #7805.
This commit is contained in:
parent
4762d52e52
commit
a7df92e187
@ -188,13 +188,19 @@ maybe_t<int> builtin_set_color(parser_t &parser, io_streams_t &streams, wchar_t
|
||||
}
|
||||
}
|
||||
|
||||
const rgb_color_t bg = rgb_color_t(bgcolor ? bgcolor : L"");
|
||||
rgb_color_t bg = rgb_color_t(bgcolor ? bgcolor : L"");
|
||||
if (bgcolor && bg.is_none()) {
|
||||
streams.err.append_format(_(L"%ls: Unknown color '%ls'\n"), argv[0], bgcolor);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
|
||||
if (print) {
|
||||
// Hack: Explicitly setting a background of "normal" crashes
|
||||
// for --print-colors. Because it's not interesting in terms of display,
|
||||
// just skip it.
|
||||
if (bgcolor && bg.is_special()) {
|
||||
bg = rgb_color_t(L"");
|
||||
}
|
||||
print_colors(streams, bold, underline, italics, dim, reverse, bg);
|
||||
return STATUS_CMD_OK;
|
||||
}
|
||||
|
@ -61,3 +61,24 @@ expect_str("white")
|
||||
expect_str("yellow")
|
||||
expect_str("normal")
|
||||
expect_prompt()
|
||||
|
||||
# This used to crash
|
||||
sendline("set_color --print-colors --background normal")
|
||||
expect_str("black")
|
||||
expect_str("blue")
|
||||
expect_str("brblack")
|
||||
expect_str("brblue")
|
||||
expect_str("brcyan")
|
||||
expect_str("brgreen")
|
||||
expect_str("brmagenta")
|
||||
expect_str("brred")
|
||||
expect_str("brwhite")
|
||||
expect_str("bryellow")
|
||||
expect_str("cyan")
|
||||
expect_str("green")
|
||||
expect_str("magenta")
|
||||
expect_str("\n\x1b[31mred")
|
||||
expect_str("\n\x1b[37mwhite")
|
||||
expect_str("\n\x1b[33myellow")
|
||||
expect_str("normal")
|
||||
expect_prompt()
|
||||
|
Loading…
x
Reference in New Issue
Block a user