From 4fd095b741798f4787a154e4a26c771af8551db9 Mon Sep 17 00:00:00 2001 From: Mark Eissler Date: Fri, 10 Jul 2015 18:11:18 -0700 Subject: [PATCH 1/2] Handle signals in git-changelog. --- bin/git-changelog | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/bin/git-changelog b/bin/git-changelog index 19445ca..3b33450 100755 --- a/bin/git-changelog +++ b/bin/git-changelog @@ -6,6 +6,7 @@ GIT_LOG_FORMAT="$(git config changelog.format)" [[ -z "$GIT_LOG_FORMAT" ]] && GIT_LOG_FORMAT=' * %s' GIT_EDITOR="$(git var GIT_EDITOR)" PROGNAME="git-changelog" +PROCLIST=() _usage() { cat << EOF @@ -306,6 +307,28 @@ commitListPretty() { commitList "$list_all" "$title_tag" "$start_tag" "$final_tag" } +_exit() { + local pid_list=() + local defaultIFS="$IFS" + local IFS="$defaultIFS" + + stty sane; echo; echo "caught signal, shutting down" + + IFS=$'\n' + pid_list=( $(pgrep -P $$) ) + IFS="$defaultIFS" + + local _pid + for _pid in "${pid_list[@]}"; do + echo "killing: ${_pid}" + kill -TERM ${_pid} + done + + wait; stty sane; exit 1 +} + +trap '_exit' SIGINT SIGQUIT SIGTERM + main() { local start_tag="null" # empty string and "null" mean two different things! local final_tag="null" @@ -433,6 +456,9 @@ main() { else mv -f "$tmpfile" "$changelog" [[ -n "$GIT_EDITOR" ]] && $GIT_EDITOR "$changelog" + if [[ $? -ne 0 ]]; then + _exit + fi fi return From 4ff5dc1ee061079a4a12106b99f8f09adaa82029 Mon Sep 17 00:00:00 2001 From: Mark Eissler Date: Wed, 15 Jul 2015 08:34:06 -0700 Subject: [PATCH 2/2] Remove unused var. --- bin/git-changelog | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/git-changelog b/bin/git-changelog index 3b33450..aff380c 100755 --- a/bin/git-changelog +++ b/bin/git-changelog @@ -6,7 +6,6 @@ GIT_LOG_FORMAT="$(git config changelog.format)" [[ -z "$GIT_LOG_FORMAT" ]] && GIT_LOG_FORMAT=' * %s' GIT_EDITOR="$(git var GIT_EDITOR)" PROGNAME="git-changelog" -PROCLIST=() _usage() { cat << EOF