Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/w default to not sorting tty names with alphabetical...



details:   https://anonhg.NetBSD.org/src/rev/eeb805d8b7d7
branches:  trunk
changeset: 366408:eeb805d8b7d7
user:      mrg <mrg%NetBSD.org@localhost>
date:      Thu May 26 02:24:00 2022 +0000

description:
default to not sorting tty names with alphabetical sort and add
a new -A switch to sort them again.

enable the sorting code if either utmp or utmpx are enabled,
not just both.  shouldn't matter as we enable both.

diffstat:

 usr.bin/w/w.1 |  12 ++++++++----
 usr.bin/w/w.c |  16 ++++++++++------
 2 files changed, 18 insertions(+), 10 deletions(-)

diffs (103 lines):

diff -r d5a85d578284 -r eeb805d8b7d7 usr.bin/w/w.1
--- a/usr.bin/w/w.1     Thu May 26 02:16:44 2022 +0000
+++ b/usr.bin/w/w.1     Thu May 26 02:24:00 2022 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: w.1,v 1.19 2018/12/06 19:15:35 sevan Exp $
+.\"    $NetBSD: w.1,v 1.20 2022/05/26 02:24:00 mrg Exp $
 .\"
 .\" Copyright (c) 1980, 1990, 1991, 1993
 .\"    The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\"     @(#)w.1        8.1 (Berkeley) 6/6/93
 .\"
-.Dd December 6, 2018
+.Dd May 25, 2022
 .Dt W 1
 .Os
 .Sh NAME
@@ -37,7 +37,7 @@
 .Nd who present users are and what they are doing
 .Sh SYNOPSIS
 .Nm
-.Op Fl hinw
+.Op Fl Ahinw
 .Op Fl M Ar core
 .Op Fl N Ar system
 .Op Ar user
@@ -61,6 +61,8 @@
 .Pp
 The options are as follows:
 .Bl -tag -width Ds
+.It Fl A
+Sort tty names alphabetically, instead of utmp or utmpx order.
 .It Fl h
 Suppress the heading.
 .It Fl i
@@ -94,7 +96,9 @@
 .Xr ps 1 ,
 .Xr uptime 1 ,
 .Xr who 1 ,
-.Xr getloadavg 3
+.Xr getloadavg 3 ,
+.Xr utmp 5 ,
+.Xr utmpx 5
 .Sh HISTORY
 The
 .Nm
diff -r d5a85d578284 -r eeb805d8b7d7 usr.bin/w/w.c
--- a/usr.bin/w/w.c     Thu May 26 02:16:44 2022 +0000
+++ b/usr.bin/w/w.c     Thu May 26 02:24:00 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: w.c,v 1.91 2021/04/17 06:14:15 maya Exp $      */
+/*     $NetBSD: w.c,v 1.92 2022/05/26 02:24:00 mrg Exp $       */
 
 /*-
  * Copyright (c) 1980, 1991, 1993, 1994
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = "@(#)w.c        8.6 (Berkeley) 6/30/94";
 #else
-__RCSID("$NetBSD: w.c,v 1.91 2021/04/17 06:14:15 maya Exp $");
+__RCSID("$NetBSD: w.c,v 1.92 2022/05/26 02:24:00 mrg Exp $");
 #endif
 #endif /* not lint */
 
@@ -95,7 +95,8 @@
 int            header = 1;     /* true if -h flag: don't print heading */
 int            nflag;          /* true if -n flag: don't convert addrs */
 int            wflag;          /* true if -w flag: wide printout */
-int            sortidle;       /* sort bu idle time */
+int            sortidle;       /* sort by idle time */
+int            alphasort;      /* sort by tty alphabeta, not numeric */
 char          *sel_user;       /* login of particular user selected */
 char           domain[MAXHOSTNAMELEN + 1];
 int maxname = 8, maxline = 3, maxhost = 16;
@@ -158,12 +159,15 @@
                options = "";
        } else {
                wcmd = 1;
-               options = "hiM:N:nw";
+               options = "AhiM:N:nw";
        }
 
        memf = nlistf = NULL;
        while ((ch = getopt(argc, argv, options)) != -1)
                switch (ch) {
+               case 'A':
+                       alphasort = 1;
+                       break;
                case 'h':
                        header = 0;
                        break;
@@ -382,8 +386,8 @@
                        *nextp = save;
                }
        }
-#if defined(SUPPORT_UTMP) && defined(SUPPORT_UTMPX)
-       else if (ehead != NULL) {
+#if defined(SUPPORT_UTMP) || defined(SUPPORT_UTMPX)
+       else if (ehead != NULL && alphasort) {
                struct entry *from = ehead, *save;
 
                ehead = NULL;



Home | Main Index | Thread Index | Old Index