Skip to content

Commit

Permalink
Merge pull request #65 from coursehero/64-support-ctrl-c
Browse files Browse the repository at this point in the history
Abort the process when SIGINT, SIGTERM and SIGKILL are notified
  • Loading branch information
siosphere committed Dec 17, 2019
2 parents cc54554 + eceb388 commit 12a56d3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion slacktee.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ function get_ok_in_response() {
echo "$(echo "$response" | awk 'match($0, /"ok":([^,}]+)/) {print substr($0, RSTART+5, RLENGTH-5)}')"
}

function handle_signal()
{
cleanup
err_exit 1 "Aborting"
}

function cleanup()
{
[[ -f $filename ]] && rm "$filename"
Expand Down Expand Up @@ -737,7 +743,7 @@ function main()
parse_args "$@"
setup_environment
check_configuration
trap cleanup SIGINT SIGTERM SIGKILL
trap handle_signal SIGINT SIGTERM SIGKILL

text=""
if [[ -n "$title" || -n "$link" ]]; then
Expand Down

0 comments on commit 12a56d3

Please sign in to comment.