Closes: #9 ps: Remove Unix98 output limitations

ps previously followed the Unix98 standard when it comes to
user-defined output, sometimes. This meant you could have
user output format with a header that included commas and
equals signs. It was dependent on if ps thought you wanted
sysv or bsd format and THAT was dependent on things in previous
options.

It was very confusing to a user because
 ps p $$ -o pid=,comm=
gave you a two-column output but
 ps -p $$ -o pid=,comm=
would give you a one column output with the header ",comm="

The -p versus p means (to ps) you want sysv or bsd parsing.
Unix98 standard or not, this is plainly just silly.

The commit removes any of the quirks Unix98 has with user defined
output.  If you really wanted a ps header with commas in the output,
today isn't your day.

Signed-off-by: Craig Small <csmall@enc.com.au>
This commit is contained in:
Craig Small
2015-10-26 11:18:52 +11:00
parent 08ef0f5714
commit b2f49b105d
4 changed files with 10 additions and 42 deletions

View File

@ -31,7 +31,6 @@
#include "common.h"
static sf_node *sf_list = NULL; /* deferred sorting and formatting */
static int broken; /* use gross Unix98 parsing? */
static int have_gnu_sort = 0; /* if true, "O" must be format */
static int already_parsed_sort = 0; /* redundantly set in & out of fn */
static int already_parsed_format = 0;
@ -205,7 +204,6 @@ double_percent:
/***************************************************************
* Used to parse option O lists. Option O is shared between
* sorting and formatting. Users may expect one or the other.
* The "broken" flag enables a really bad Unix98 misfeature.
* Put each completed format_node onto the list starting at ->f_cooked
*/
static const char *format_parse(sf_node *sfn){
@ -235,9 +233,6 @@ static const char *format_parse(sf_node *sfn){
}
need_item=1;
break;
case '=':
if(broken) goto out;
/* fall through */
default:
if(need_item) items++;
need_item=0;
@ -499,7 +494,6 @@ static const char *short_sort_parse(sf_node *sfn){
/*
* Used to parse option O lists. Option O is shared between
* sorting and formatting. Users may expect one or the other.
* The "broken" flag enables a really bad Unix98 misfeature.
* Recursion is to preserve original order.
*/
static const char *parse_O_option(sf_node *sfn){
@ -750,12 +744,9 @@ static const char *generate_sysv_list(void){
* sorting and formatting. Users may expect one or the other.
* The "broken" flag enables a really bad Unix98 misfeature.
*/
const char *process_sf_options(int localbroken){
const char *process_sf_options(void){
sf_node *sf_walk;
if(personality & PER_BROKEN_o) localbroken = 1;
if(personality & PER_GOOD_o) localbroken = 0;
broken = localbroken;
if(sf_list){
const char *err;
err = parse_O_option(sf_list);