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.)
This commit is contained in:
kre 2017-08-24 01:43:42 +00:00
parent 8f3f249e43
commit 9f2931ceb6
2 changed files with 4 additions and 12 deletions

View File

@ -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>
.\" All rights reserved.
@ -79,9 +79,6 @@ If no arguments are provided, then all of the
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 @@ The
.Nm
script was written by
.An Alistair Crooks Aq Mt agc@NetBSD.org .
.Sh BUGS
Component names containing spaces given as arguments do not work.

View File

@ -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>
# 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 @@ run() {
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 @@ if [ $# -eq 0 ]; then
set -- ''
all=true
else
# note this deletes any attempt to use '' as an arg.
set -- $( printf '%s\n' "$@" | sort -u )
all=false
fi