core_trap.sh 372 B

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