>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 [email protected]:/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:
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "[email protected]"

Reply via email to