Advertisement
Guest User

Untitled

a guest
Mar 6th, 2014
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.48 KB | None | 0 0
  1. #!/bin/bash
  2. set -e
  3. set -o pipefail
  4.  
  5. function echoTraps() {
  6.     echo "= on start:"
  7.     trap -p
  8.     trap -- 'echo func-EXIT' EXIT
  9.     echo "= after set new:"
  10.     trap -p
  11.     # we can ensure after script done - file '/tmp/tmp.txt' was not created
  12.     trap -- 'echo SIG 1>/tmp/tmp.txt' SIGPIPE SIGHUP SIGINT SIGQUIT SIGTERM
  13. }
  14.  
  15. trap -- 'echo main-EXIT1' EXIT
  16.  
  17. echo "===== subshell trap"
  18. ( echoTraps; )
  19.  
  20. echo "===== pipe trap"
  21. echoTraps | cat
  22.  
  23. echo "===== done everything"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement