Bug 454370 - headers format parsing wrong (e.g. ps -o pid=,cmd=)
headers format parsing wrong (e.g. ps -o pid=,cmd=)
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: procps (Show other bugs)
All Linux
low Severity medium
: rc
: ---
Assigned To: Daniel Novotny
Brian Brock
Depends On:
  Show dependency treegraph
Reported: 2008-07-07 21:42 EDT by Mikel Ward
Modified: 2009-05-10 10:25 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2008-07-21 03:14:55 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Mikel Ward 2008-07-07 21:42:18 EDT
POSIX says you can disable the ps header by making all field headers null

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=

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

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


The problem also appears to happen on my Fedora 9 laptop, which has
Comment 1 Mikel Ward 2008-07-15 03:46:27 EDT
Ew.  They changed the behavior in the latest POSIX standard.

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


  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 03:14:55 EDT
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 02:29:15 EDT
$ ps -o pid=,cmd=
$ PS_PERSONALITY=linux ps -o pid=,cmd=
6496 bash
6533 ps -o pid=,cmd=
$ PS_PERSONALITY=posix ps -o pid=,cmd=

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.