[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Freeze exception request for mythtv-status



* Andrew Ruthven [Tue, 04 Nov 2008 14:08:32 +1300]:

> Gidday,

Hello,

> +    # Just incase someone has removed their motd file.
> +    [ ! -f /var/run/motd ] && touch /var/run/motd
>      [ ! -f /var/run/motd.orig ] && cp /var/run/motd /var/run/motd.orig

This is wrong for a `set -e` script. If those files exist, the left part
of the expression will fail, and the script will abort. The proper way
to do it is:

      [ -f /var/run/motd ] || touch /var/run/motd
      [ -f /var/run/motd.orig ] || cp /var/run/motd /var/run/motd.orig

> +    set +e
> +    $DAEMON $ARGS -h $HOST >> /var/run/motd.new 2> /dev/null
> +    ret=$?
> +    set -e

A more idiomatic way to do it, in case you like it better, is:

       ret=0
       $DAEMON $ARGS -h $HOST >> /var/run/motd.new 2> /dev/null || ret=$?

HTH,

-- 
Adeodato Simó                                     dato at net.com.org.es
Debian Developer                                  adeodato at debian.org
 
- You look beaten.
- I just caught Tara laughing with another man.
- Are you sure they weren't just... kissing or something?
- No, they were laughing.
                -- Denny Crane and Alan Shore


Reply to: