As it's already known, top(1) receive options from three places:
  * from TOP enviornment variable;
  * from command line;
  * from user input (in interactive mode).

Some options are actually simple switches, namely -1CHISu. But handling
of those switches when specified in TOP or on the command line differs:
some of them make corresponding options always on, and some switch the
values back and forth. This patch makes all such options real switches.
I.e., if you have TOP="-H -1 -s 2" and want to acquire non-threaded output,
you don't have to use monsters such as ``TOP="-1 -s 2" top''.

Any opinions/okays?


Index: top.c
===================================================================
RCS file: /cvs/src/usr.bin/top/top.c,v
retrieving revision 1.79
diff -u -p -r1.79 top.c
--- top.c       8 Jun 2012 13:41:16 -0000       1.79
+++ top.c       14 Jan 2013 11:38:44 -0000
@@ -139,10 +139,10 @@ parseargs(int ac, char **av)
        while ((i = getopt(ac, av, "1SHICbinqus:d:p:U:o:g:")) != -1) {
                switch (i) {
                case '1':
-                       combine_cpus = 1;
+                       combine_cpus = !combine_cpus;
                        break;
                case 'C':
-                       show_args = Yes;
+                       show_args = !show_args;
                        break;
                case 'u':       /* toggle uid/username display */
                        do_unames = !do_unames;
@@ -182,8 +182,8 @@ parseargs(int ac, char **av)
                        break;
 
                case 'H':       /* show threads */
-                       ps.threads = Yes;
-                       old_threads = Yes;
+                       ps.threads = !ps.threads;
+                       old_threads = ps.threads;
                        break;
 
                case 'I':       /* show idle processes */

Reply via email to