From f379d691e54dd2e103f8a36d063999bcdb8b2729 Mon Sep 17 00:00:00 2001 From: Edwin Groothuis Date: Mon, 11 Jul 2011 10:41:08 +0000 Subject: [PATCH] ncal(1) highlights the current date (or a date provided via parameter) even if stdout is not a tty. If stdout is not a tty the data is normally processed by other tools and no control sequences are expected. PR: bin/158580 MFC after: 1 week --- usr.bin/ncal/ncal.1 | 2 ++ usr.bin/ncal/ncal.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/usr.bin/ncal/ncal.1 b/usr.bin/ncal/ncal.1 index 8429906395ca..bd3b71c25e86 100644 --- a/usr.bin/ncal/ncal.1 +++ b/usr.bin/ncal/ncal.1 @@ -171,6 +171,8 @@ that, two after that and the whole year. will warn about these combinations. .Pp A year starts on January 1. +.P +Highlighting of dates is disabled if stdout is not a tty. .Sh SEE ALSO .Xr calendar 3 , .Xr strftime 3 diff --git a/usr.bin/ncal/ncal.c b/usr.bin/ncal/ncal.c index 44e31fec1db6..2ca770a2b781 100644 --- a/usr.bin/ncal/ncal.c +++ b/usr.bin/ncal/ncal.c @@ -822,7 +822,8 @@ mkmonthr(int y, int m, int jd_flag, struct monthlines *mlines) dt.d = j - jan1 + 1; else sdater(j, &dt); - if (j == highlightdate && !flag_nohighlight) + if (j == highlightdate && !flag_nohighlight + && isatty(STDOUT_FILENO)) highlight(mlines->lines[i] + k, ds + dt.d * dw, dw, &l); else