diff options
author | Karel Zak | 2019-02-04 14:16:11 +0100 |
---|---|---|
committer | Karel Zak | 2019-02-04 14:20:03 +0100 |
commit | f90d8b8bccc8f410dd6dc36a028889ea3169b26b (patch) | |
tree | dbb5c7670c4736ae1e09d8eafdc3682ca83595e6 /misc-utils | |
parent | lib/colors: force to "never" mode on non-terminal output (diff) | |
download | kernel-qcow2-util-linux-f90d8b8bccc8f410dd6dc36a028889ea3169b26b.tar.gz kernel-qcow2-util-linux-f90d8b8bccc8f410dd6dc36a028889ea3169b26b.tar.xz kernel-qcow2-util-linux-f90d8b8bccc8f410dd6dc36a028889ea3169b26b.zip |
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 <nunojsilva@ist.utl.pt>
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'misc-utils')
-rw-r--r-- | misc-utils/cal.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/misc-utils/cal.c b/misc-utils/cal.c index 4dff491fb..bd643f3b4 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) { |