[arch-general] [PATCH 1/2] kill_everything: Reduce number of -f tests

Dave Reisner d at falconindy.com
Tue Sep 7 23:47:52 EDT 2010


Instead of checking for the existance of a file in /var/run/daemons on
every iteration, handle the null case by setting nullglob. The shopt
call is done inside a subshell as to not bother the environment since we
may be going to runlevel 1 only temporarily.
---
 functions |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/functions b/functions
index b9ba718..7a0c4f8 100644
--- a/functions
+++ b/functions
@@ -206,11 +206,13 @@ kill_everything() {
     # $1 = where we are being called from.
     # This is used to determine which hooks to run.
     # Find daemons NOT in the DAEMONS array. Shut these down first
+    (
+    shopt -s nullglob
     for daemon in /var/run/daemons/*; do
-        [[ -f $daemon ]] || continue
         daemon=${daemon##*/}
 	in_array "$daemon" "${DAEMONS[@]}" || stop_daemon "$daemon"
     done
+    )
 
     # Shutdown daemons in reverse order
     for ((i=${#DAEMONS[@]}-1; i>=0; i--)); do
-- 
1.7.2.3



More information about the arch-general mailing list