From: Karel Zak Date: Mon, 4 Feb 2019 13:16:11 +0000 (+0100) Subject: cal: use standout mode on monochrome terminals X-Git-Tag: v2.34-rc1~134 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f90d8b8bccc8f410dd6dc36a028889ea3169b26b;p=thirdparty%2Futil-linux.git cal: use standout mode on monochrome terminals The function colors_init() checks for colors, it means it fails on monochrome terminals, but cal(1) in this case still need to highlight the current day. Reported-by: Nuno Silva Signed-off-by: Karel Zak --- diff --git a/misc-utils/cal.c b/misc-utils/cal.c index 4dff491fb6..bd643f3b49 100644 --- a/misc-utils/cal.c +++ b/misc-utils/cal.c @@ -550,9 +550,21 @@ int main(int argc, char **argv) headers_init(&ctl); - if (!colors_init(ctl.colormode, "cal")) { - ctl.req.day = 0; - ctl.weektype &= ~WEEK_NUM_MASK; + if (colors_init(ctl.colormode, "cal") == 0) { + /* + * If standout mode available (Senter and Sexit are set) and + * user or terminal-colors.d do not disable colors than + * ignore colors_init(). + */ + if (*Senter && *Sexit && colors_mode() != UL_COLORMODE_NEVER) { + /* let use standout mode */ + ; + } else { + /* disable */ + Senter = Sexit = '\0'; + ctl.req.day = 0; + ctl.weektype &= ~WEEK_NUM_MASK; + } } if (yflag || Yflag) {