Skip to content

Instantly share code, notes, and snippets.

@hacker65536
Created October 24, 2016 06:13
Show Gist options
  • Save hacker65536/fdb262ec30a0b3fb41b41e65a84b79a9 to your computer and use it in GitHub Desktop.
Save hacker65536/fdb262ec30a0b3fb41b41e65a84b79a9 to your computer and use it in GitHub Desktop.
trap test
#!/bin/bash
set -me
function exitf(){
echo "catch exit"
}
function excep(){
echo "catch exception"
}
# EXITシグナルをtrapして終了メッセージを指定する。
trap exitf EXIT
# 他のシグナルもtrapしておく。
trap excep 1 2 3 15
# Ctrl+Cで終了するテストのためにsleepしておく。
sleep 10
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment