Date: Sun, 10 Jan 2010 12:03:18 GMT From: "N.J. Mann" <njm@njm.me.uk> To: FreeBSD-gnats-submit@FreeBSD.org Subject: bin/142570: [PATCH] clean up quiet mode (-q | --quiet) output of pkg_version(1) Message-ID: <201001101203.o0AC3IKT070730@titania.njm.me.uk> Resent-Message-ID: <201001101210.o0ACA10k068649@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>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@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:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201001101203.o0AC3IKT070730>