The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 04-23-2009
EagleFlyFree EagleFlyFree is offline
Registered User
  
 

Join Date: Apr 2009
Posts: 13
Specifically about reporting and exiting, this is a slightly more condensed idiom:


Code:
test $condition || { print "Crap blew up; exiting"; exit 2; }

You could also directly test for the result of your command:


Code:
command || { print "Crap blew up; exiting"; exit 2; }

I enjoy reading that out loud to myself as "either you do this or DIE!", as if threathening the script.

Last edited by EagleFlyFree; 04-23-2009 at 03:17 PM..