3
0

exit.tests 684 B

12345678910111213141516171819202122232425262728293031323334
  1. "$THIS_SH" -c 'trap "echo cow" 0'
  2. "$THIS_SH" -c 'trap "echo moo" EXIT'
  3. "$THIS_SH" -c 'trap "echo no" 0; trap 0'
  4. (
  5. exitfunc() {
  6. echo "Traps1:"
  7. trap
  8. # EXIT trap is disabled after it is triggered,
  9. # it can not be "re-armed" like this:
  10. trap "echo Should not run" EXIT
  11. echo "Traps2:"
  12. trap
  13. }
  14. trap 'exitfunc' EXIT
  15. exit 42
  16. )
  17. echo Check1: $?
  18. (
  19. exitfunc() {
  20. echo "Traps1:"
  21. trap
  22. # EXIT trap is disabled after it is triggered,
  23. # it can not be "re-armed" like this:
  24. trap "echo Should not run" EXIT
  25. echo "Traps2:"
  26. trap
  27. exit 42
  28. }
  29. trap 'exitfunc' EXIT
  30. exit 66
  31. )
  32. echo Check2: $?