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.
This commit is contained in:
parent
fd0c7d1ecd
commit
4350eb0487
|
@ -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 @@ and the name and arguments of the current process.
|
|||
.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 @@ list of users on the system
|
|||
.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
|
||||
|
|
|
@ -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 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1991, 1993, 1994\
|
|||
#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 argwidth; /* width of tty left to print process args */
|
|||
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 @@ main(int argc, char **argv)
|
|||
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 @@ main(int argc, char **argv)
|
|||
*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;
|
||||
|
|
Loading…
Reference in New Issue