]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
cal: use standout mode on monochrome terminals
authorKarel Zak <kzak@redhat.com>
Mon, 4 Feb 2019 13:16:11 +0000 (14:16 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 4 Feb 2019 13:20:03 +0000 (14:20 +0100)
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 <nunojsilva@ist.utl.pt>
Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/cal.c

index 4dff491fb63ba3adcbc699e0a48bfbb03810c872..bd643f3b49ed87a4bef30074d80d76ceebdbe74d 100644 (file)
@@ -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) {