[arch-projects] [INITSCRIPTS][PATCH] rc.d: list [started|stopped|auto|noauto|daemon]

Dave Reisner d at falconindy.com
Tue Aug 23 06:10:59 EDT 2011


On Tue, Aug 23, 2011 at 11:57:20AM +0200, Lukas Fleischer wrote:
> On Tue, Aug 23, 2011 at 10:36:27AM +0200, Seblu wrote:
> > On Tue, Aug 23, 2011 at 10:01 AM, Lukas Fleischer
> > >> +             esac
> > >> +     done
> > >> +     # if no daemon are specified take all executable file in /etc/rc.d
> > >> +     if ! [[ $daemons ]]; then
> > >
> > > "[[ ! $daemons ]]". Or any reason to do the negation outside the
> > > conditional expression here?
> > Reason to do it inside ?
> 
> Only a matter of clarity and coding style. If we want to check for a
> false value explicitly, having the negation inside the conditional
> expression makes things clearer. "! [[ $daemons ]]" looks like "Check if
> $daemons is defined. If that is not true, do [...]". "[[ ! $daemons ]]"
> looks like "If $daemons is undefined, do [...]". If you don't feel like
> doing it or if you always use negations outside the conditional brackets
> in initscripts, just keep it :)

If you want to be consistent, we use '[[ -z' everywhere else. '[[ !'
isn't wrong, its just unexpected in our codebase.

> > 
> > >
> > >> +             cd /etc/rc.d
> > >> +             for d in *; do
> > >> +                     [[ -x "$d" && ! -d "$d" ]] && daemons=(${daemons[@]} "$d")
> > >
> > > 'daemons=("${daemons[@]}" "$d")'. Just to be sure we don't fail here if
> > > a daemon ever contains a space (and since you used proper quoting
> > > everywhere else).
> > i tested with a daemon with space. np.

Generally we use array+=("$another"). There's nothing wrong with this
persay, just don't reverse it -- bash is exponentially slower when
prepending to an array.

> ----
> <eww zsh>

d


More information about the arch-projects mailing list