Bug#580825: above fix isn't quite right

Neil Moore neil at s-z.org
Sun May 16 05:37:37 UTC 2010


This fix isn't quite right, because it will try running checkarray
even if the checkarray script is not there (e.g. if the package is
removed but not purged) or is not executable.  In fact, in this case
the above version will try running checkarray every sunday, thus
generating a weekly "command not found" email---even with older
versions of cron that do not send emails on mere nonzero exit status.
Better would be:

  if [ -x /usr/share/mdadm/checkarray ] && [ $(date +\%d) -le 7 ]; then /usr/share/mdadm/checkarray --cron --all --quiet; fi

If either condition is false, nothing is executed and if's exit status
is zero.


It would also be possible to keep a zero exit status by inverting the
first test:

  [ ! -x /usr/share/mdadm/checkarray ] || [ $(date +\%d) -gt 7 ] || /usr/share/mdadm/checkarray --cron --all --quiet

But, although this version is slightly shorter than the one with 'if',
I think it is less readable.  One shouldn't have to apply de Morgan's
laws to figure out when checkarray is going to be called.

-- 
Neil Moore, neil at s-z.org, http://s-z.org/neil/





More information about the pkg-mdadm-devel mailing list