[arch-projects] [initscripts] [PATCH 07/11] functions: Simplify ck_autostart() by refactoring using in_array()
Dave Reisner
d at falconindy.com
Sat Jul 2 15:09:36 EDT 2011
On Sat, Jul 02, 2011 at 08:44:25PM +0200, Kurt J. Bosch wrote:
> ---
> functions | 6 +-----
> 1 files changed, 1 insertions(+), 5 deletions(-)
>
> diff --git a/functions b/functions
> index 11f8317..a8ef211 100644
> --- a/functions
> +++ b/functions
> @@ -198,11 +198,7 @@ have_daemon() {
>
> # Check if $1 is started at boot
> ck_autostart() {
> - local d
> - for d in "${DAEMONS[@]}"; do
> - [[ "$1" = ${d#@} ]] && return 1
> - done
> - return 0
> + in_array "$1" "${DAEMONS[@]}" && return 1 || return 0
This isn't the same. You've completely ignored any daemon started in the
background. You could naively trim the DAEMONS list:
in_array "$1" "${DAEMONS[@]#@}"
The return isn't necessary -- its implicitly provided by the return of
in_array.
dave
> }
>
> start_daemon() {
> --
> 1.7.1
>
More information about the arch-projects
mailing list