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

@ -285,14 +285,7 @@ static const char *set_personality(void){
return NULL;
case_default: /* use defaults for ps, ignoring other environment variables */
return NULL;
case_unknown: /* defaults, but also check inferior environment variables */
if(
getenv("UNIX95") /* Irix */
|| getenv("POSIXLY_CORRECT") /* most gnu stuff */
|| (getenv("POSIX2") && !strcmp(getenv("POSIX2"), "on")) /* Unixware 7 */
) personality = PER_BROKEN_o;
return NULL;
case_aix:
@ -334,8 +327,9 @@ static const char *set_personality(void){
case_irix:
case_sgi:
s = getenv("_XPG");
if(s && s[0]>'0' && s[0]<='9') personality = PER_BROKEN_o;
else personality = PER_IRIX_l;
if(s && s[0]>'0' && s[0]<='9')
return NULL;
personality = PER_IRIX_l;
return NULL;
case_os390: /* IBM's OS/390 OpenEdition on the S/390 mainframe */
@ -346,13 +340,13 @@ static const char *set_personality(void){
case_hp:
case_hpux:
personality = PER_BROKEN_o | PER_HPUX_x;
personality = PER_HPUX_x;
return NULL;
case_svr4:
case_sysv:
case_sco:
personality = PER_BROKEN_o | PER_SVR4_x;
personality = PER_SVR4_x;
return NULL;
case_posix:
@ -360,7 +354,6 @@ static const char *set_personality(void){
case_unix95:
case_unix98:
case_unix:
personality = PER_BROKEN_o;
return NULL;
}