bin/142570: [PATCH] clean up quiet mode (-q | --quiet) output of pkg_version(1)

N.J. Mann njm at njm.me.uk
Sun Jan 10 12:10:02 UTC 2010


>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:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Jan 10 12:10:01 UTC 2010
>Closed-Date:
>Last-Modified:
>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 at 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:
>Unformatted:


More information about the freebsd-bugs mailing list