From dca0209b67114ebe3fa3231c61a1ae2769375468 Mon Sep 17 00:00:00 2001 From: Antoine Jacoutot Date: Thu, 3 Nov 2016 12:27:35 +0000 Subject: Simplify for loops; prompted by a comment from rpe@ --- usr.sbin/syspatch/syspatch.sh | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'usr.sbin/syspatch') diff --git a/usr.sbin/syspatch/syspatch.sh b/usr.sbin/syspatch/syspatch.sh index 91477e8b401..566c57fa064 100644 --- a/usr.sbin/syspatch/syspatch.sh +++ b/usr.sbin/syspatch/syspatch.sh @@ -1,6 +1,6 @@ #!/bin/ksh # -# $OpenBSD: syspatch.sh,v 1.26 2016/11/02 18:04:50 ajacoutot Exp $ +# $OpenBSD: syspatch.sh,v 1.27 2016/11/03 12:27:34 ajacoutot Exp $ # # Copyright (c) 2016 Antoine Jacoutot # @@ -166,10 +166,9 @@ ls_avail() ls_installed() { local _p - # no _REL dir = no installed patch - cd ${_PDIR}/${_REL} 2>/dev/null && set -- * || return 0 - for _p; do - [[ ${_p} = rollback-syspatch-${_RELINT}-*.tgz ]] && + for _p in ${_PDIR}/${_REL}/*; do + _p=${_p:##*/} + [[ ${_p} = rollback-syspatch-${_RELINT}-*.tgz ]] && _p=${_p#rollback-} && echo ${_p%.tgz} done | sort -V } @@ -224,15 +223,13 @@ sp_cleanup() local _d _k # remove non matching release /var/syspatch/ content - cd ${_PDIR} && set -- * - for _d; do + for _d in ${_PDIR}/*; do [[ -e ${_d} ]] || continue - [[ ${_d} == ${_REL} ]] || rm -r ${_d} + [[ ${_d:##*/} == ${_REL} ]] || rm -r ${_d} done # remove non matching release rollback kernel - set -- /bsd.rollback* - for _k; do + for _k in /bsd.rollback*; do [[ -f ${_k} ]] || continue [[ ${_k} == /bsd.rollback${_RELINT} ]] || rm ${_k} done -- cgit v1.2.3