Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 11th, 2012  |  syntax: None  |  size: 0.27 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. run code on failure
  2. set -e
  3. set -u
  4.        
  5. a
  6. .a
  7. .a_onfail
  8.        
  9. # headers etc
  10. DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
  11. $(DIR)/.a || $(DIR)/.a_onfail
  12.        
  13. trap ... ERR
  14.        
  15. #!/bin/sh -eu
  16.  
  17. main() {
  18.   echo "$X"
  19. }
  20.  
  21. on_failure() {
  22.   echo "Failure"
  23. }
  24.  
  25. (main) || on_failure