Date: Fri, 1 Jul 2011 23:18:00 +0200 (CEST) From: Tobias Rehbein <tobias.rehbein@web.de> To: FreeBSD-gnats-submit@FreeBSD.org Subject: bin/158580: [patch] Disable ncal(1)s date highlighting if stdout is not a tty Message-ID: <201107012118.p61LI02m029652@sushi.pseudo.local> Resent-Message-ID: <201107012120.p61LKAks011602@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 158580 >Category: bin >Synopsis: [patch] Disable ncal(1)s date highlighting if stdout is not a tty >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Fri Jul 01 21:20:09 UTC 2011 >Closed-Date: >Last-Modified: >Originator: Tobias Rehbein >Release: FreeBSD 8.2-RELEASE-p2 i386 >Organization: >Environment: System: FreeBSD sushi.pseudo.local 8.2-RELEASE-p2 FreeBSD 8.2-RELEASE-p2 #4: Thu Jun 2 16:42:39 CEST 2011 tobi@sushi.pseudo.local:/usr/obj/usr/src/sys/SUSHI i386 >Description: 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. The attached patch disables the higlighting of dates if stdout is not a tty which seems to be "the right thing to do". >How-To-Repeat: >Fix: --- usr.bin-ncal_conditional-highlight.diff begins here --- diff -ruN usr.bin/ncal.orig/ncal.1 usr.bin/ncal/ncal.1 --- usr.bin/ncal.orig/ncal.1 2011-07-01 22:37:47.000000000 +0200 +++ usr.bin/ncal/ncal.1 2011-07-01 22:36:58.000000000 +0200 @@ -171,6 +171,8 @@ will warn about these combinations. .Pp A year starts on January 1. +.Pp +Highlighting of dates is diabled if stdout is not a tty. .Sh SEE ALSO .Xr calendar 3 , .Xr strftime 3 diff -ruN usr.bin/ncal.orig/ncal.c usr.bin/ncal/ncal.c --- usr.bin/ncal.orig/ncal.c 2011-07-01 22:37:47.000000000 +0200 +++ usr.bin/ncal/ncal.c 2011-07-01 22:34:26.000000000 +0200 @@ -822,7 +822,7 @@ 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 --- usr.bin-ncal_conditional-highlight.diff ends here --- >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201107012118.p61LI02m029652>