Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 454370 - headers format parsing wrong (e.g. ps -o pid=,cmd=)
Summary: headers format parsing wrong (e.g. ps -o pid=,cmd=)
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: procps
Version: 4.6
Hardware: All
OS: Linux
low
medium
Target Milestone: rc
: ---
Assignee: Daniel Novotny
QA Contact: Brian Brock
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2008-07-08 01:42 UTC by Mikel Ward
Modified: 2009-05-10 14:25 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2008-07-21 07:14:55 UTC


Attachments (Terms of Use)

Description Mikel Ward 2008-07-08 01:42:18 UTC
POSIX says you can disable the ps header by making all field headers null
http://www.opengroup.org/onlinepubs/009695399/utilities/ps.html

The -o option allows the output format to be specified under user control.

The application shall ensure that the format specification is a list of names
presented as a single argument, <blank> or comma-separated. Each variable has a
default header. The default header can be overridden by appending an equals sign
and the new text of the header. The rest of the characters in the argument shall
be used as the header text. The fields specified shall be written in the order
specified on the command line, and should be arranged in columns in the output.
The field widths shall be selected by the system to be at least as wide as the
header text (default or overridden value). If the header text is null, such as
-o user=, the field width shall be at least as wide as the default header text.
If all header text fields are null, no header line shall be written.

This doesn't seem to be working on RHEL4.  Instead, it appears to be setting the
header for the first column to the specifier for the second column.

# ps -o pid=,cmd=
,cmd=
31721
32307
32581

It should give output equivalent to ps -o pid,cmd but without the header line,
e.g. if ps -o pid,cmd gives this:

  PID CMD
31721 /bin/bash
32307 vi inst
32617 ps -o pid,cmd

Then ps -o pid=,cmd= should give this:

31721 /bin/bash
32307 vi inst
32617 ps -o pid,cmd

procps-3.2.3-8.9

The problem also appears to happen on my Fedora 9 laptop, which has
procps-3.2.7-20.fc9.i386.

Comment 1 Mikel Ward 2008-07-15 07:46:27 UTC
Ew.  They changed the behavior in the latest POSIX standard.

When they say "argument", they now mean everything in the argument to -o:

  APPLICATION USAGE

  There is no special quoting mechanism for header text. The header text is
  the rest of the argument. If multiple header changes are needed, multiple -o
  options can be used, such as:

  ps -o "user=User Name" -o pid=Process\ ID



Comment 2 Tomas Smetana 2008-07-21 07:14:55 UTC
This must be changed in the upstream version first and definitely won't get
there from RHEL.  No API changes should appear in stable releases.  

Comment 3 Albert Cahalan 2009-05-10 06:29:15 UTC
$ ps -o pid=,cmd=
,cmd=
 6496
 6532
$ PS_PERSONALITY=linux ps -o pid=,cmd=
6496 bash
6533 ps -o pid=,cmd=
$ PS_PERSONALITY=posix ps -o pid=,cmd=
,cmd=
 6496
 6534

The default personality is POSIX (insane) unless you use
a non-POSIX option.

I encourage you to point out to the POSIX committee that
nobody likes the insane POSIX parsing. They have a mailing
list, austin-group-l@opengroup.org if I remember right,
where you can send edits to the standard. The comma should
just be unavailable; quoting is certainly not required.
(if they insist, use ",," to put a common in a header)
Probably you'll get better luck making "," after "=" have
undefined behavior, but a few years later somebody may
see that as an omission and restore the insanity.


Note You need to log in before you can comment on or make changes to this bug.