ps enhencements (posix syntax, and more)
Cyrille Lefevre
clefevre-lists at 9online.fr
Sat Apr 24 08:18:40 PDT 2004
"Garance A Drosihn" <drosih at rpi.edu> wrote:
> At 3:19 AM +0200 4/23/04, Cyrille Lefevre wrote:
> >"Albert Cahalan" <albert at users.sourceforge.net> wrote:
> >>
> >> No, the point was that adding **any** option to switch
> >> parser modes kind of defeats the whole idea of trying
> >> to be compatible with anything.
> >
> >as suggested by Garrett Wollman, I will change -qQ to -W
> >something, as done before through -X posix,etc. which have
> >been retired from the current version.
>
> Don't go changing things around yet again. I don't think
> Garrett *requested* a change. He just pointed out that -W
> is reserved "for the implementation".
I'll work on later, since it is better to have only one option to switch
between more than mode than to have multiple options. As I do it
w/ my original -X options (a kind of, but much simplier).
> > > You can switch via $PATH and/or some other environment variable.
> >
> >currently, mode switch is also done through [...] and using
> >an environment variable (see another email about that).
> >but, some others dislike environment variables...
>
> I have no intention of installing any updates which cause `ps'
> to completely change it's behavior and accepted options based
> on the value of an environment variable.
gnu's have _POSIXLY_CORRECT and other systems have a similary
environment variable. why don't us ? for script portability, it may be much
simplier to say BLAH=yes, than to modify the whole script, IMHO.
> > > > static char bsd_fmtstr[] = "\
> >> > label:Z user:[ju](n!)& uid:([ju]n&)([ls]([ju]!)&)| pid:2! ppid:[jl] \
> >> > pgid:j sid:jX& tpgid:jX& tsid:jX& jobc:j sig:s sigmask:s sigignore:s \
> >> > sigcatch:s cpu:l pri:l nice:l %cpu:u %mem:u vsz:[lu] rss:[lu] \
> >> > mwchan:l(n!)& nwchan:ln& tt:[d2u](vX&)| state:1! tt:[jls]([du]!)& \
> >> > start:u time:1! sl:v re:v pagein:v vsz:v([lu]!)& rss:v([lu]!)& lim:v \
> >> > tsiz:v %cpu:v(u!)& %mem:v(u!)& command:1! \
> >> > ";
> >>
> >> I am reminded of sendmail. You're getting close.
> >
> >maybe, but this kept the code as small as possible. encode this
> >using if else if etc. and the code will be at least twice the
> >actual one.
>
> I am not sure of all that that section of code is doing, but I
> will say that I am a little uncomfortable with how cryptic that
> fmtstr is.
well, at the first time, I use a simplier solution, but it was not working in
some
case. so, the answer was to implement a reverse-polish-calculator bcoz "it is
really simple to implement, even if the syntax isn't so easy to understand".
1 and 2 are used by before and after -O fmtlist
j, l, n, s, u, v and Z are enabled by -j, -l, -n, -s, -u, -v and -Z
d is the default format string, X is enabled by -Q
label:Z -> Z
user:[ju](n!)& -> (j or u) and (not n)
uid:([ju]n&)([ls]([ju]!)&)| -> (n and (j or u)) or ((l or s) and (not (j or u)))
pid:2! -> not 2
ppid:[jl] -> j or u
pgid:j -> j
sid:jX& tpgid:jX& tsid:jX& -> j and X
jobc:j -> j
sig:s sigmask:s sigignore:s sigcatch:s -> s
cpu:l pri:l nice:l -> l
%cpu:u %mem:u -> u
vsz:[lu] rss:[lu] -> (l or u)
mwchan:l(n!)& -> l and (not n)
nwchan:ln& -> l and n
=> I may implement -n as -c is implemented ?
tt:[d2u](vX&)| -> (d or 2 or u) or (v and X)
state:1! -> not 1
tt:[jls]([du]!)& -> (j or l or s) and (not (d or u))
=> already printed by d or u
start:u -> u
time:1! -> not 1
sl:v re:v pagein:v -> v
vsz:v([lu]!)& rss:v([lu]!)& -> v and (not (l or u))
=> already printed by l or u
lim:v tsiz:v -> v
%cpu:v(u!)& %mem:v(u!)& -> v and (not u)
=> already printed by u
command:1! -> not 1
is that help you ?
Cyrille Lefevre.
--
home: mailto:cyrille.lefevre at laposte.net
More information about the freebsd-standards
mailing list