From 92e978439f0c3139775ad96d412959f5a74b17b6 Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Fri, 13 Jan 2023 13:19:03 -0700 Subject: [PATCH] cal: don't print terminal control characters unless stdout is a TTY A similar change was made in svn r223931, but it was incomplete, working only when the utility was invoked as "ncal". Fix the same issue when invoking as "cal". PR: 268936 Reported by: Ray Bellis MFC after: 2 weeks Sponsored by: Axcient Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D38045 --- usr.bin/ncal/ncal.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/usr.bin/ncal/ncal.c b/usr.bin/ncal/ncal.c index 8f94264efcd..5a6c33ce759 100644 --- a/usr.bin/ncal/ncal.c +++ b/usr.bin/ncal/ncal.c @@ -930,7 +930,8 @@ mkmonthb(int y, int m, int jd_flag, struct monthlines *mlines) dt.d = j - jan1 + 1; else sdateb(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