On Thu, 30 Aug 2007, Richard Hobbs wrote: > ====================================================================== > echo "Updating rules..." && /usr/bin/sa-update && echo "Done, now > checking config syntax..." && spamassassin --lint && echo "Done, now > restarting spamd..." && /etc/init.d/spamassassin restart && echo "Done" > ====================================================================== > > However, if there are no updates (and sa-update exits with an exit code > of 1) i would like to print "No updates, exiting" and then exit. > > So i modified it to become this: > > ====================================================================== > echo "Updating rules..." && /usr/bin/sa-update && echo "Done, now > checking config syntax..." || echo "No updates, exiting"; exit && > spamassassin --lint && echo "Done, now restarting spamd..." && > /etc/init.d/spamassassin restart && echo "Done" > ====================================================================== > > However, whether there are updates or not, the script still exits - do > you know which syntax i need to use here (i'm using bash, btw).
I'd recommend rewriting that to use if ... then ... else ... fi syntax. Pasting stuff together with && and || is only manageable when the logic is simple and straightforward. Perhaps (off the top of my head): echo "Updating rules..." if /usr/bin/sa-update then echo "Done, now checking config syntax..." if spamassassin --lint then echo "Syntax OK, now restarting spamd..." /etc/init.d/spamassassin restart echo "Done" else echo "Syntax error in update, please manually review!" fi else echo "No updates, exiting." fi -- John Hardin KA7OHZ http://www.impsec.org/~jhardin/ [EMAIL PROTECTED] FALaholic #11174 pgpk -a [EMAIL PROTECTED] key: 0xB8732E79 -- 2D8C 34F4 6411 F507 136C AF76 D822 E6E6 B873 2E79 ----------------------------------------------------------------------- There is no doubt in my mind that millions of lives could have been saved if the people were not "brainwashed" about gun ownership and had been well armed. ... Gun haters always want to forget the Warsaw Ghetto uprising, which is a perfect example of how a ragtag, half-starved group of Jews took 10 handguns and made asses out of the Nazis. -- Theodore Haas, Dachau Survivor ----------------------------------------------------------------------- 20 days until Talk Like a Pirate day