top: provide command line sort field override switches

This commit adds two new command line switches dealing
with the potential need to automate/script the setting
of top's current sort field independent of the rcfile.

The -o (lower case) switch requires a lone valid field
name as an argument, from among the 42 currently used.
Then, it overrides the config file's Curwin->sortindx.

And since field names are now translatable, they could
diverge from those reflected in the documentation. So,
a 2nd switch of -O (upper case) is also provided which
outputs all names as translated and understood by top.

(now that we know a '.' + 2 spaces is squeezed to one)
(everything's perfectly justified, but it's just luck)

Reference(s):
Bug-Redhat: https://bugzilla.redhat.com/871844
http://www.freelists.org/post/procps/PATCH-Allow-core-file-generation-by-ps-command-rhbz871825-rhbz512857,9
http://www.freelists.org/post/procps/PATCH-Allow-core-file-generation-by-ps-command-rhbz871825-rhbz512857,15
http://www.freelists.org/post/procps/PATCH-Allow-core-file-generation-by-ps-command-rhbz871825-rhbz512857,16

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner
2012-12-13 00:00:00 -06:00
committed by Craig Small
parent d747659ad8
commit 407d1fc8f2
4 changed files with 45 additions and 14 deletions

View File

@@ -53,8 +53,9 @@
.ds CG \'current\' window/field group
.ds CI interactive command
\# - Note: our 'Command Line' used in 2 places
.ds CL \-\fBhv\fR|\-\fBbcHiSs\fR \-\fBd\fR delay \-\fBn\fR limit \
\-\fBu\fR|\fBU\fR user \-\fBp\fR pid[,pid] \-\fBw\fR [cols] \fR
\# ( and managed to fit in an 80x24 terminal )
.ds CL \-\fBhv\fR|\-\fBbcHiOSs\fR \-\fBd\fR secs \-\fBn\fR max \
\-\fBu\fR|\fBU\fR user \-\fBp\fR pid \-\fBo\fR fld \-\fBw\fR [cols] \fR
.ds CO command\-line option
.ds CT command toggle
.ds CW \'current\' window
@@ -301,6 +302,21 @@ For additional information regarding this toggle
Specifies the maximum number of iterations, or frames, \*(We should
produce before ending.
.TP 5
\-\fBo\fR :\fI Override-sort-field\fR as:\fB\ \ \-o fieldname \fR
Specifies the name of the field on which tasks will be sorted, independent
of what is reflected in the configuration file.
This option exists primarily to support automated/scripted batch mode
operation.
.TP 5
\-\fBO\fR :\fI Output-field-names \fR
This option acts as a form of help for the above \-o option.
It will cause \*(We to print each of the available field names on a
separate line, then quit.
Such names are subject to nls translation.
.TP 5
\-\fBp\fR :\fI Monitor-PIDs\fR mode as:\fB\ \ \-pN1 -pN2 ...\fR\ \ or\fB\ \ \-pN1,N2,N3 ... \fR
Monitor only processes with specified process IDs.