In the old days, a "ps -e" on Linux would get you something like this:
warning: `-' deprecated; use `ps e', not `ps -e' PID TTY STAT TIME COMMAND ..
To get that now, you need to use "oldps". The man page (which you can still see with "man oldps") warned:
For now, ps will give you a warning if you use a `-' for a short option, but it will still work. If you have shell scripts which use BSD-style arguments to ps, take heed of the warning and fix them, or else your scripts will fail to function correctly at some point in the future. If you want to turn off the warnings, set the I_WANT_A_BROKEN_PS environment variable.
When I first saw this, it ticked me off. From time to time, I've even made comments like:
Personally, I think bsd ps semantics are "broken", not the other way around. But if I were putting in such a flag, I'd call it "I_WANT_BSD_FLAGS".
Well, I was wrong. Albert Cahalan (see the end of "man ps") set me straight:
I think Michael K. Johnson named that option, not me, but I support the naming and the code behind it. If you set that option, you make ps violate the POSIX and UNIX standards. The common "ps -ef" command will not work. (this is an ISO, IEEE, Open Group, and ANSI standard) According to the standards, "ps -aux" is parsed the same way as "ps -a -u x", with "x" being a username! People who want the BSD options get them by default anyway, with less typing. Why type "ps -aux" when "ps aux" will work? Besides, it's more portable to leave off the "-". You can use "ps aux" on AIX or Tru64, along with "ps -ef", but you can't use "ps -aux" on those systems at all. I like using both BSD and UNIX syntax, sometimes together. For example: ps f -ef ps -C bash,xterm u
OK, I see the error of my ways. But.. the new ps doesn't seem to mind using "ps -e" at all. So the warning seems not to have come true, at least not yet.
Reading the newer "man ps", I found this :
PS_PERSONALITY Description () () none "Do the right thing" aix like AIX ps bsd like FreeBSD ps compaq like Digital Unix ps debian like the old Debian ps digital like Digital Unix ps gnu like the old Debian ps hp like HP-UX ps hpux like HP-UX ps irix like Irix ps linux deviate from Unix98 for convenience only old like the original Linux ps posix standard sco like SCO ps sgi like Irix ps sun like SunOS 4 ps sunos like SunOS 4 ps sysv standard unix standard unix95 standard unix98 standard
That made me think that if I set PS_PERSONALITY to "old" (and exported it) that "ps -e" would act like "oldps -e", but it doesn't (at least not on the system I tried it on). However, setting and exporting CMD_ENV did alter the behaviour as expected, though you don't get the "deprecated" message.
It's fun to play with the various settings. I notice that "sco" is one of the options, though I'm not sure what effects that has. Perhaps it causes "ps" to spawn a lawsuit?
See How "ps" works and why also.
Got something to add? Send me email.
More Articles by Tony Lawrence © 2011-03-20 Tony Lawrence
Principles have no real force except when one is well-fed. (Mark Twain)
"I notice that 'sco' is one of the options, though I'm not sure what effects that has. Perhaps it causes "ps" to spawn a lawsuit?"
That happens only if the DARL_MCBRIDE environment variable has been set.
Regarding the ps semantics, I really don't appreciate some of these ADD-suffering coders intentionally deviating from the POSIX standards so as avoid typing one or two extra characters. I have enough trouble keeping all this stuff straight in my head without someone arbitrarily adding to the confusion. Let's try to maintain syntactical uniformity, even if it means typing that dreaded minus sign.
--BigDumbDinosaur
---July 24, 2004
I've been told that "oldps" no longer exists (I was using an older RedHat server) and that PS_PERSONALITY now works just as CMD_ENV did here.
The problem with the "-" stuff is this: BSD never required a "-", and unfortunately some of their option letters have different meanings. So how should "ps -e" be interpreted? Should it show the environment or every process? Setting PS_PERSONALITY lets you force that decision, otherwise the new "ps" tries hard to "do the right thing". Albert has sent me some longer explanations of this which I have asked permisson to publish.
--TonyLawrence
Printer Friendly Version
I_WANT_A_BROKEN_PS Copyright © July 2004 Tony Lawrence
Related Articles
Have you tried Searching this site?
This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more.
Contact us
Printer Friendly Version