summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrpe <rpe@openbsd.org>2016-04-11 18:47:05 +0000
committerrpe <rpe@openbsd.org>2016-04-11 18:47:05 +0000
commit8dd4cc9ba0956fde1f641aa072c433ce7e911f71 (patch)
tree89f5e413c2a9b2df1bb24a76e8a30cdee337ad11
parentThis code chunk has been disabled since its import, and what is does is (diff)
downloadwireguard-openbsd-8dd4cc9ba0956fde1f641aa072c433ce7e911f71.tar.xz
wireguard-openbsd-8dd4cc9ba0956fde1f641aa072c433ce7e911f71.zip
Tweak bsort():
- make it clear in comment that it returns a unique list - shift is only possible if argc > 0, otherwise return - quote "$_b" in equality test forcing possible patterns being treated as strings OK halex@, krw@
-rw-r--r--distrib/miniroot/install.sub20
1 files changed, 9 insertions, 11 deletions
diff --git a/distrib/miniroot/install.sub b/distrib/miniroot/install.sub
index 278d4f3f2ab..359a4b871f8 100644
--- a/distrib/miniroot/install.sub
+++ b/distrib/miniroot/install.sub
@@ -1,5 +1,5 @@
#!/bin/ksh
-# $OpenBSD: install.sub,v 1.890 2016/04/09 15:14:47 rpe Exp $
+# $OpenBSD: install.sub,v 1.891 2016/04/11 18:47:05 rpe Exp $
#
# Copyright (c) 1997-2015 Todd Miller, Theo de Raadt, Ken Westerback
# Copyright (c) 2015, Robert Peichaer <rpe@openbsd.org>
@@ -91,20 +91,18 @@ waitcgiinfo() {
# Utils functions
# ------------------------------------------------------------------------------
-# Sort and print provided arguments.
+# Sort and print unique list of provided arguments.
bsort() {
- local _l _a=$1 _b
+ local _a=$1 _b _l
- (($# > 0)) || return
+ (($#)) && shift || return
- shift
for _b; do
- if [[ $_a != $_b ]]; then
- if [[ $_a > $_b ]]; then
- _l="$_a $_l"; _a=$_b
- else
- _l="$_b $_l"
- fi
+ [[ $_a == "$_b" ]] && continue
+ if [[ $_a > $_b ]]; then
+ _l="$_a $_l" _a=$_b
+ else
+ _l="$_b $_l"
fi
done