From james@now.ie  Thu Sep 26 05:47:28 2002
Return-Path: <james@now.ie>
Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id BFE4937B401
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 26 Sep 2002 05:47:28 -0700 (PDT)
Received: from mail.kerna.ie (ns.kerna.ie [194.106.143.66])
	by mx1.FreeBSD.org (Postfix) with ESMTP id DD29543E6A
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 26 Sep 2002 05:47:19 -0700 (PDT)
	(envelope-from james@now.ie)
Received: from ram.kerna.ie (ram.kerna.ie [194.106.143.99])
	by mail.kerna.ie (8.9.3/8.9.3) with ESMTP id NAA10146
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 26 Sep 2002 13:47:18 +0100 (BST)
Received: from bender.kerna.ie (68mj4dtyfga35nel@bender.kerna.ie [192.168.42.133])
	by ram.kerna.ie (8.9.3/8.9.3) with ESMTP id NAA00746
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 26 Sep 2002 13:47:15 +0100
Received: (from james@localhost)
	by bender.kerna.ie (8.11.6/8.11.6) id g8QClAG71375;
	Thu, 26 Sep 2002 13:47:10 +0100 (IST)
	(envelope-from james@now.ie)
Message-Id: <200209261247.g8QClAG71375@bender.kerna.ie>
Date: Thu, 26 Sep 2002 13:47:10 +0100 (IST)
From: James Raftery <james@now.ie>
Reply-To: James Raftery <james@now.ie>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [PATCH] ps(1) prints blank line if no headers specified
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         43389
>Category:       bin
>Synopsis:       [PATCH] ps(1) prints blank line if no headers specified
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Sep 26 05:50:01 PDT 2002
>Closed-Date:    Sat Nov 30 05:14:52 PST 2002
>Last-Modified:  Sat Nov 30 05:14:52 PST 2002
>Originator:     James Raftery
>Release:        FreeBSD 4.5-RELEASE-p18 i386
>Organization:
<None>
>Environment:
System: FreeBSD bender.kerna.ie 4.5-RELEASE-p18 FreeBSD 4.5-RELEASE-p18 #2: Wed Aug 7 10:16:16 IST 2002 root@bender.kerna.ie:/usr/obj/usr/src/sys/BENDER i386


>Description:

	ps(1) prints a blank line when no column headers are specified.


>How-To-Repeat:

	With headers:

	ocelot:lecter$ ps -o pid=p -o cpu=c -p 1
	    p   c
	    1   0
	ocelot:lecter$ 


	Without headers:

	ocelot:lecter$ ps -o pid= -o cpu= -p 1
		 
	    1   0
	ocelot:lecter$ 

>Fix:

	Patch below which scans the header list and stops
	printheader() if there are no headers to print.


#
# Verified to apply to:
#   /usr/src/bin/ps/print.c revisions 1.36.2.2 and 1.36.2.3
#
# This patch stops ps(1) from printing a blank line when no/empty
# headers are specified. Apply the patch, then 'make all install' in
# /usr/src/bin/ps.
#
# James Raftery <james@now.ie>
#

--- print.c.orig	Thu Sep 26 11:35:36 2002
+++ print.c	Thu Sep 26 12:56:42 2002
@@ -67,6 +67,16 @@
 {
 	VAR *v;
 	struct varent *vent;
+	int i;
+
+	for (vent = vhead; vent; vent = vent->next) {
+		v = vent->var;
+		if (strlen(v->header) > 0)
+			i = 1;
+	}
+
+	if (i != 1)
+		return;
 
 	for (vent = vhead; vent; vent = vent->next) {
 		v = vent->var;

>Release-Note:
>Audit-Trail:

From: James Raftery <james@now.ie>
To: freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: bin/43389: [PATCH] ps(1) prints blank line if no headers specified
Date: Fri, 22 Nov 2002 16:36:33 +0000

 Hi,
 
 I've cleaned up the patch slightly. It's at:
  http://romana.now.ie/software/freebsd-ps.format.patch
 
 ATB,
 james
State-Changed-From-To: open->closed 
State-Changed-By: tjr 
State-Changed-When: Sat Nov 30 05:06:53 PST 2002 
State-Changed-Why:  
This was recently fixed in -current and MFC'd today.. I didn't know about 
this PR until now. 

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