On Fri, Nov 7, 2008 at 20:05:02 +0100, Adeodato Simó wrote: > * 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 > FWIW, set -e won't abort the script with the above code (well, unless touch or cp fail). From dash(1):
-e errexit If not interactive, exit immediately if any untested command fails. The exit status of a com‐ mand is considered to be explicitly tested if the command is used to control an if, elif, while, or until; or if the command is the left hand operand of an “&&” or “||” operator. Cheers, Julien -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]