4
0

core_trap.sh 509 B

123456789101112131415161718192021222324
  1. #!/bin/bash
  2. # LinuxGSM core_trap.sh module
  3. # Author: Daniel Gibbs
  4. # Contributors: https://linuxgsm.com/contrib
  5. # Website: https://linuxgsm.com
  6. # Description: Handles CTRL-C trap to give an exit code.
  7. moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
  8. fn_exit_trap() {
  9. local saved_exit_status=$?
  10. echo -e ""
  11. if [ -z "${exitcode}" ]; then
  12. exitcode=${saved_exit_status}
  13. fi
  14. if [ -z "${exitcode}" ]; then
  15. exitcode=0
  16. fi
  17. core_exit.sh
  18. }
  19. # trap to give an exit code.
  20. trap fn_exit_trap INT