summaryrefslogtreecommitdiff
path: root/usr.sbin/syspatch
diff options
context:
space:
mode:
authorAntoine Jacoutot <ajacoutot@cvs.openbsd.org>2016-09-10 16:19:15 +0000
committerAntoine Jacoutot <ajacoutot@cvs.openbsd.org>2016-09-10 16:19:15 +0000
commit772fb79f5d8129e545393a381ffb9b836bc68db9 (patch)
tree67cce8e9fa4b394ab632433fe0cf843b693c9f08 /usr.sbin/syspatch
parent89711ae33960e945ee7284ae71f5bd9b1540c95a (diff)
Drop syspatch_trap, it's simple enough for trap no needing its own function.
Introduce sp_err() which will get used for error messages.
Diffstat (limited to 'usr.sbin/syspatch')
-rw-r--r--usr.sbin/syspatch/syspatch.sh18
1 files changed, 8 insertions, 10 deletions
diff --git a/usr.sbin/syspatch/syspatch.sh b/usr.sbin/syspatch/syspatch.sh
index d95c6e9d914..653eb5cede4 100644
--- a/usr.sbin/syspatch/syspatch.sh
+++ b/usr.sbin/syspatch/syspatch.sh
@@ -1,6 +1,6 @@
#!/bin/ksh
#
-# $OpenBSD: syspatch.sh,v 1.12 2016/09/10 16:07:33 ajacoutot Exp $
+# $OpenBSD: syspatch.sh,v 1.13 2016/09/10 16:19:14 ajacoutot Exp $
#
# Copyright (c) 2016 Antoine Jacoutot <ajacoutot@openbsd.org>
#
@@ -18,23 +18,21 @@
set -e
-trap "syspatch_trap" 2 3 9 13 15 ERR
+trap "rm -rf ${_TMP}; exit 1" 2 3 9 13 15 ERR
-usage()
+sp_err()
{
- echo "usage: ${0##*/} [-c | -l | -r]" >&2 && return 1
+ echo "${@}" 1>&2 && return 1
}
-needs_root()
+usage()
{
- [[ $(id -u) -ne 0 ]] && echo "${0##*/}: need root privileges" && \
- return 1
+ sp_err "usage: ${0##*/} [-c | -l | -r]"
}
-syspatch_trap()
+needs_root()
{
- rm -rf ${_TMP}
- exit 1
+ [[ $(id -u) -ne 0 ]] && sp_err "${0##*/}: need root privileges"
}
apply_patches()