From njm@njm.me.uk  Sun Jan 10 12:03:21 2010
Return-Path: <njm@njm.me.uk>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 2F64B106568D
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 10 Jan 2010 12:03:21 +0000 (UTC)
	(envelope-from njm@njm.me.uk)
Received: from smtp004.apm-internet.net (smtp004.apm-internet.net [85.119.248.54])
	by mx1.freebsd.org (Postfix) with SMTP id 966348FC2A
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 10 Jan 2010 12:03:20 +0000 (UTC)
Received: (qmail 92211 invoked from network); 10 Jan 2010 12:03:19 -0000
Received: from unknown (HELO oberon.njm.me.uk) (86.138.89.30)
  by smtp004.apm-internet.net with SMTP; 10 Jan 2010 12:03:19 -0000
Received: from titania.njm.me.uk (titania.njm.me.uk [192.168.144.130])
	by oberon.njm.me.uk (8.14.3/8.14.3) with ESMTP id o0AC3JJY035452
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 10 Jan 2010 12:03:19 GMT
	(envelope-from njm@oberon.njm.me.uk)
Received: from titania.njm.me.uk (localhost [127.0.0.1])
	by titania.njm.me.uk (8.14.3/8.14.3) with ESMTP id o0AC3IdL070731
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 10 Jan 2010 12:03:18 GMT
	(envelope-from njm@titania.njm.me.uk)
Received: (from njm@localhost)
	by titania.njm.me.uk (8.14.3/8.14.3/Submit) id o0AC3IKT070730;
	Sun, 10 Jan 2010 12:03:18 GMT
	(envelope-from njm)
Message-Id: <201001101203.o0AC3IKT070730@titania.njm.me.uk>
Date: Sun, 10 Jan 2010 12:03:18 GMT
From: "N.J. Mann" <njm@njm.me.uk>
Reply-To: "N.J. Mann" <njm@njm.me.uk>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [PATCH] clean up quiet mode (-q | --quiet) output of pkg_version(1)
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         142570
>Category:       bin
>Synopsis:       [PATCH] clean up quiet mode (-q | --quiet) output of pkg_version(1)
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bapt
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Jan 10 12:10:01 UTC 2010
>Closed-Date:    Tue Oct 02 17:07:51 UTC 2012
>Last-Modified:  Tue Oct 02 17:07:51 UTC 2012
>Originator:     N.J. Mann
>Release:        FreeBSD 7.2-STABLE i386
>Organization:
>Environment:
System: FreeBSD titania.njm.me.uk 7.2-STABLE FreeBSD 7.2-STABLE #23 r201635M: Wed Jan 6 10:00:37 GMT 2010 njm@titania.njm.me.uk:/usr/obj/usr/src/sys/titania i386


	
>Description:
	In non-verbose non-quiet mode the output from pkg_version(1) is padded
with spaces to a fixed length (printf "%-34s") and then either a '<', '=' or
'>' character is output followed by a newline character.  In quiet mode the
'<', '=' or '>' character is replaced by a NUL (0x0).  I can see no reason for
the NUL and it needlessly complicates things when the output of pkg_version is
a pipeline.  Similarly, I see no need for the padding in quiet mode.
>How-To-Repeat:
	
>Fix:

	The attached patch cleans up the output in quiet-mode.

--- pkg_patch.diff begins here ---
Index: usr.sbin/pkg_install/version/perform.c
===================================================================
--- usr.sbin/pkg_install/version/perform.c	(revision 201718)
+++ usr.sbin/pkg_install/version/perform.c	(working copy)
@@ -308,19 +308,31 @@
 	ver = strrchr(latest, '-');
 	ver = ver ? &ver[1] : latest;
 	if (cmp < 0 && OUTPUT('<')) {
-	    printf("%-34s  %c", tmp, Quiet ? '\0' : '<');
-	    if (Verbose)
-		printf("   needs updating (%s has %s)", source, ver);
+	    if (Quiet)
+		printf("%s", tmp);
+	    else {
+		printf("%-34s  <", tmp);
+		if (Verbose)
+		    printf("   needs updating (%s has %s)", source, ver);
+	    }
 	    printf("\n");
 	} else if (cmp == 0 && OUTPUT('=')) {
-	    printf("%-34s  %c", tmp, Quiet ? '\0' : '=');
-	    if (Verbose)
-		printf("   up-to-date with %s", source);
+	    if (Quiet)
+		printf("%s", tmp);
+	    else {
+		printf("%-34s  =", tmp);
+		if (Verbose)
+		    printf("   up-to-date with %s", source);
+	    }
 	    printf("\n");
 	} else if (cmp > 0 && OUTPUT('>')) {
-	    printf("%-34s  %c", tmp, Quiet ? '\0' : '>');
-	    if (Verbose)
-		printf("   succeeds %s (%s has %s)", source, source, ver);
+	    if (Quiet)
+		printf("%s", tmp);
+	    else {
+		printf("%-34s  >", tmp);
+		if (Verbose)
+		    printf("   succeeds %s (%s has %s)", source, source, ver);
+	    }
 	    printf("\n");
 	}
     }
--- pkg_patch.diff ends here ---


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->portmgr 
Responsible-Changed-By: flz 
Responsible-Changed-When: Thu Apr 1 17:20:03 UTC 2010 
Responsible-Changed-Why:  
pkg_install is maintained by portmgr. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=142570 
State-Changed-From-To: open->analyzed 
State-Changed-By: flz 
State-Changed-When: Fri Apr 2 11:54:17 UTC 2010 
State-Changed-Why:  
Patch looks good. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=142570 
State-Changed-From-To: analyzed->patched 
State-Changed-By: bapt 
State-Changed-When: Tue Sep 18 22:12:46 UTC 2012 
State-Changed-Why:  
awaiting MFC 


Responsible-Changed-From-To: portmgr->bapt 
Responsible-Changed-By: bapt 
Responsible-Changed-When: Tue Sep 18 22:12:46 UTC 2012 
Responsible-Changed-Why:  
awaiting MFC 

http://www.freebsd.org/cgi/query-pr.cgi?pr=142570 
State-Changed-From-To: patched->closed 
State-Changed-By: bapt 
State-Changed-When: Tue Oct 2 17:07:50 UTC 2012 
State-Changed-Why:  
MFCed, thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=142570 
>Unformatted:
