posix ps (was Re: Adding `pgrep' and `pkill' to /usr/bin)

Harti Brandt brandt at fokus.fraunhofer.de
Sun Mar 28 23:38:15 PST 2004


On Mon, 29 Mar 2004, Stephen McKay wrote:

SM>On Sunday, 28th March 2004, Harti Brandt wrote:
SM>
SM>>Well, that is just like LANG or LC_ALL. You cannot depend on parsing
SM>>utility output until you set LC_ALL=C, yet I have still to see a script
SM>>that does this.
SM>
SM>Yes, that is a significant deficiency of the internationalisation scheme.
SM>That doesn't mean we should copy it though.
SM>
SM>>If you happen to write a script for BSD syntax just put LC_ALL=C
SM>>PERSONALITY=BSD on top of it.
SM>
SM>Hopefully in the near future there will be a universally accepted default
SM>for ps options.  Are you seriously suggesting that every script forevermore
SM>will have to put PERSONALITY=STANDARD (or similar) in front of a two
SM>character command name just to defeat this misfeature?

Well, I'm rather thinking that the PERSONALITY that gets set at the begin
of the script gives you the default for all the commands in that script.
If you take a BSD script setting PERSONALITY=BSD should be fine, if you
happen to use a script coming from Slowaris PERSONALITY=SYSV or whatever
will do the job. IF you need a BSD option inside a SYSV script, THEN
you have to specify that just for the single command. If you use command
line options to select the behaviour you would need to equip your entire
BSD script with the command line options to select BSD behaviour for all
the commands in it. You simply have no way to specify a default.

SM>>SM>If multiple personalities is a desirable trait (and it's not clear that it
SM>>SM>is) then command line switches and aliases are the correct mechanisms to
SM>>SM>use.
SM>>
SM>>That would require to add that switch to all utility calls in a script
SM>>that have multiple personalities. Thats far from being desirable.
SM>
SM>I don't understand.  I was suggesting that if end users want different
SM>flavours of output they can select them with command line switches and
SM>aliases (if this is an option at all).  This is as opposed to allowing
SM>users to select the default via an environment variable, which would
SM>negatively impact the use of ps in scripts.
SM>
SM>I can't see why scripts would want to use anything but the standard options.
SM>You only want to parse one format.

Think of 'ls -o'. -o is taken by posix to mean the same as '-l' but
without showing the group. FreeBSD ls instead takes it to show file flags.
This is a more obvious case where you want the selection.

Also if a have dozens of scripts which have worked on BSD for a long time,
I'm ready to put a PERSONALITY=BSD on top of them, but I don't think I
want to go through them line by line to find out which of the utilities is
now SysV conform and needs another set of switches or for which utility I
have to use which switch to get the BSD syntax. THIS negatively
impacts the use in scripts.

harti


More information about the freebsd-arch mailing list