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

Victor Lowther victor.lowther at gmail.com
Wed Sep 8 00:16:45 EDT 2010


On Tue, Sep 7, 2010 at 10:47 PM, Dave Reisner <d at falconindy.com> wrote:
> 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.

I thought about just enabling nullglobs and extglobs unconditionally
in functions, but decided that was too likely to get objections no
matter how unlikely breakage was. :)

> ---
>  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