Change to "kludge option processing" in /bin/ps

Garance A Drosihn drosih at
Fri May 28 10:25:47 PDT 2004

At 5:51 PM +0200 5/28/04, Jilles Tjoelker wrote:
>On Sun, May 23, 2004, Garance A Drosihn wrote:
>>  If anyone wants to try the update, it is available at:
>  >
>  > Assuming there aren't any major objections to these ideas, I plan
>  > to do some more testing on this and commit it next weekend.
>What's the deeper purpose of the `optlist' argument for
>`kludge_oldps_options' if it's always set to PS_ARGS?

a) After a future update, it may be set to something else.
b) An earlier version of this update called the kludge-
    processing for all remaining arguments, and used NULL for
    optlist to distinguish between argument #1 and "all the
    rest".  After a little testing I realized that that idea
    was simply not going to work the way I wanted it to, so
    I got rid of that code but left the parameter.

>I have some doubts on whether `ps t' instead of `ps T' should
>still be supported, since `ps t p0' doesn't work because of it.
>You could only change 't' to 'T' when there are no more

Hmm, that is an interesting point.  I'll check into it.  I should
note that I'm not going to knock myself out trying to create ideal
processing for the historical '-'-less options.  However I do think
I might be able to improve on the 't'-kludge a little bit more.

>Am I right that `ps U0' is equivalent to `ps -U0' with the patch?
>(This wasn't really much of an issue before `-U' accepted uids
>instead of names.)

Yes, after the patch `ps U0' == `ps -U0'
Before the patch, `ps U0' ==   ps: No user named 'p0'

>What happens when you do `ps 1,2,3,4'? And `ps uww0,1'? Or even
>`ps "v1 $$"'?

`ps 1,2,3,4' == `ps -p 1,2,3,4'
`ps uww0,1'  == `ps -uww -p0,1'
`ps u ww0,1'  == an error, since kludge processing is only
                  done on argument #1
`ps v1 10'   == `ps -p1 -p10'
`ps "v1 10"' ==  an error, for reasons unrelated to this update

>All this complexity makes me think of not using getopt(3), as
>Albert Cahalan suggested :)

Eh.  I don't think it's all that bad, not yet at least.  As long
as we limit "kludge" (the "-"-less option) processing to the first
argument, I think we can use getopt() without too much trouble.

Garance Alistair Drosehn            =   gad at
Senior Systems Programmer           or  gad at
Rensselaer Polytechnic Institute    or  drosih at

More information about the freebsd-arch mailing list