Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/sys_info Get rid of the arg sorting - it doesn't wor...



details:   https://anonhg.NetBSD.org/src/rev/f183c1d66e11
branches:  trunk
changeset: 826255:f183c1d66e11
user:      kre <kre%NetBSD.org@localhost>
date:      Thu Aug 24 01:43:42 2017 +0000

description:
Get rid of the arg sorting - it doesn't work properly, and makes it
impossible to support component names containing embedded \n's (the
similar embedded space problem would have been trivial to fix.)
Deleting the sorting makes those issues moot, the args are no longer
processed, hence can be anything.

An alternative would be to sort the results - but that would separate
the -v output from the real output (-v stuff is not rationally sortable)
and also makes it much more difficult to get the error code for an
unknown component (like one containing an embedded \n !) as the pipe
to strt that would be used would cause the while loop to run in a sub-shell
(effectively.)

diffstat:

 usr.bin/sys_info/sys_info.1  |  7 +------
 usr.bin/sys_info/sys_info.sh |  9 +++------
 2 files changed, 4 insertions(+), 12 deletions(-)

diffs (64 lines):

diff -r 0a4c3f65a0b8 -r f183c1d66e11 usr.bin/sys_info/sys_info.1
--- a/usr.bin/sys_info/sys_info.1       Thu Aug 24 01:01:09 2017 +0000
+++ b/usr.bin/sys_info/sys_info.1       Thu Aug 24 01:43:42 2017 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: sys_info.1,v 1.3 2017/08/23 01:17:46 kre Exp $
+.\" $NetBSD: sys_info.1,v 1.4 2017/08/24 01:43:42 kre Exp $
 .\"
 .\" Copyright (c) 2016 Alistair Crooks <agc%NetBSD.org@localhost>
 .\" All rights reserved.
@@ -79,9 +79,6 @@
 items that are known to
 .Nm
 are reported.
-.Pp
-If arguments are provided, the output is displayed in
-alphabetical order, and duplicates are removed.
 .Sh EXIT STATUS
 .Nm
 exits with status 2 if an unknown option is given,
@@ -103,5 +100,3 @@
 .Nm
 script was written by
 .An Alistair Crooks Aq Mt agc%NetBSD.org@localhost .
-.Sh BUGS
-Component names containing spaces given as arguments do not work.
diff -r 0a4c3f65a0b8 -r f183c1d66e11 usr.bin/sys_info/sys_info.sh
--- a/usr.bin/sys_info/sys_info.sh      Thu Aug 24 01:01:09 2017 +0000
+++ b/usr.bin/sys_info/sys_info.sh      Thu Aug 24 01:43:42 2017 +0000
@@ -1,6 +1,6 @@
 #! /bin/sh
 
-# $NetBSD: sys_info.sh,v 1.11 2017/08/23 21:18:57 agc Exp $
+# $NetBSD: sys_info.sh,v 1.12 2017/08/24 01:43:42 kre Exp $
 
 # Copyright (c) 2016 Alistair Crooks <agc%NetBSD.org@localhost>
 # All rights reserved.
@@ -26,7 +26,7 @@
 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #
 
-SYS_INFO_VERSION=20170823
+SYS_INFO_VERSION=20170824
 
 PATH=$(sysctl -n user.cs_path)
 export PATH
@@ -102,8 +102,7 @@
 getversion() {
        case "$1" in
        '')
-               # arriving here implies all==true, not possible otherwise
-               ;&
+               $all || return 0 ;&
        awk)
                run "awk --version | awk '{ print \$1 \"-\" \$3 }'"
                $all || return 0 ;&
@@ -255,8 +254,6 @@
        set -- ''
        all=true
 else
-       # note this deletes any attempt to use '' as an arg.
-       set -- $( printf '%s\n' "$@" | sort -u )
        all=false
 fi
 



Home | Main Index | Thread Index | Old Index