{"thread":{"id":"3127","subject":"git cherry unkillable","startedAt":"2006-01-22T10:23:26Z","lastAt":"2006-01-22T15:48:50Z","messageCount":7,"participants":["Andrey Borzenkov","sean"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"15032","messageId":"200601221323.33377.arvidjaar@mail.ru","threadId":"3127","inReplyTo":null,"subject":"git cherry unkillable","fromName":"Andrey Borzenkov","fromEmail":"arvidjaar@mail.ru","sentAt":"2006-01-22T10:23:26Z","receivedAt":"2006-01-22T10:23:26Z","isPatch":false,"sender":{"key":"arvidjaar@mail.ru","avatar":null},"body":"-----BEGIN PGP SIGNED MESSAGE-----\nHash: SHA1\n\nI mistakenly run git cherry on linus tree which was a bit too much for my poor \nold system. Trying to kill (^C) it I got\n\n{pts/0}% git cherry ali1535 linus\nexternal diff died, stopping at include/linux/sysctl.h.\nexternal diff died, stopping at drivers/serial/suncore.c.\ndiff: /home/bor/tmp/.diff_Y6CvCw: No such file or directory\ndiff: /home/bor/tmp/.diff_tBqCCk: No such file or directory\nexternal diff died, stopping at include/asm-arm/arch-pxa/pxa-regs.h.\nexternal diff died, stopping at fs/cifs/file.c.\nexternal diff died, stopping at MAINTAINERS.\ndiff: /home/bor/tmp/.diff_P12uX9: No such file or directory\ndiff: /home/bor/tmp/.diff_R4v0g0: No such file or directory\nexternal diff died, stopping at net/ipv4/route.c.\n....\n\nand it jut goes on. This takes really some time here so ability to stop it \nwould be really nice. It still runs with CPU temp rocketing.\n\nRegards\n\n- -andrey\n-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1.4.2 (GNU/Linux)\n\niD8DBQFD010lR6LMutpd94wRArDIAKC4yNPpwZ2AEKpXwjeZREMRCL3VyACeJaYu\nUMZUpX3D3UfHSm0m44pvAmY=\n=0Cxg\n-----END PGP SIGNATURE-----\n"},{"id":"15033","messageId":"BAYC1-PASMTP10435A067270A659801A48AE110@CEZ.ICE","threadId":"3127","inReplyTo":"200601221323.33377.arvidjaar@mail.ru","subject":"Re: git cherry unkillable","fromName":"sean","fromEmail":"seanlkml@sympatico.ca","sentAt":"2006-01-22T11:39:04Z","receivedAt":"2006-01-22T11:39:04Z","isPatch":false,"sender":{"key":"seanlkml@sympatico.ca","avatar":"https://gravatar.com/avatar/f92923f54fc08c401fc59b71829d4b89e9b8087fbba45ff87c82e6a83aee02ae?d=mp&s=160"},"body":"On Sun, 22 Jan 2006 13:23:26 +0300\nAndrey Borzenkov <arvidjaar@mail.ru> wrote:\n\n> Hash: SHA1\n> \n> I mistakenly run git cherry on linus tree which was a bit too much for my poor \n> old system. Trying to kill (^C) it I got\n> \n> {pts/0}% git cherry ali1535 linus\n> external diff died, stopping at include/linux/sysctl.h.\n> external diff died, stopping at drivers/serial/suncore.c.\n> diff: /home/bor/tmp/.diff_Y6CvCw: No such file or directory\n> diff: /home/bor/tmp/.diff_tBqCCk: No such file or directory\n> external diff died, stopping at include/asm-arm/arch-pxa/pxa-regs.h.\n> external diff died, stopping at fs/cifs/file.c.\n> external diff died, stopping at MAINTAINERS.\n> diff: /home/bor/tmp/.diff_P12uX9: No such file or directory\n> diff: /home/bor/tmp/.diff_R4v0g0: No such file or directory\n> external diff died, stopping at net/ipv4/route.c.\n> ....\n> \n> and it jut goes on. This takes really some time here so ability to stop it \n> would be really nice. It still runs with CPU temp rocketing.\n> \n\nOuch yeah, you'd have to explicitly kill -9 from another command line.   The\nsame problem exists in a few other scripts too, although probably none that\ncan be as long lived as git-cherry.   \n\nThe attached patch works for me but i'm concerned about it a bit.  With this\npatch it looks like the signal handler is executed twice; once as normal and\na second time in response to the added \"exit\" statement.   By adding \n\";trap - 0;exit\" it is only executed once, but i'm not sure how universal that\nis, and letting it run twice shouldn't be a big deal anyway.\n\nThe other minor concern is that exit should maybe return an error value\ninstead; but that isn't approprirate when handling signal zero.   So it\nmight be better to have a separate trap for signal zero, but in the end\nit doesn't seem worth the bother.\n\nSean\n\n\tdiff --git a/git-cherry.sh b/git-cherry.sh\nindex 1a62320..a1e4d70 100755\n--- a/git-cherry.sh\n+++ b/git-cherry.sh\n@@ -49,7 +49,7 @@ ours=`git-rev-list $ours ^$limit` || exi\n tmp=.cherry-tmp$$\n patch=$tmp-patch\n mkdir $patch\n-trap \"rm -rf $tmp-*\" 0 1 2 3 15\n+trap \"rm -rf $tmp-*;exit\" 0 1 2 3 15\n \n _x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'\n _x40=\"$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40\"\ndiff --git a/git-format-patch.sh b/git-format-patch.sh\nindex 7e67c4e..38adaad 100755\n--- a/git-format-patch.sh\n+++ b/git-format-patch.sh\n@@ -77,7 +77,7 @@ tt)\n esac\n \n tmp=.tmp-series$$\n-trap 'rm -f $tmp-*' 0 1 2 3 15\n+trap 'rm -f $tmp-*;exit' 0 1 2 3 15\n \n series=$tmp-series\n commsg=$tmp-commsg\ndiff --git a/git-ls-remote.sh b/git-ls-remote.sh\nindex f699268..ba96969 100755\n--- a/git-ls-remote.sh\n+++ b/git-ls-remote.sh\n@@ -38,7 +38,7 @@ peek_repo=\"$(get_remote_url \"$@\")\"\n shift\n \n tmp=.ls-remote-$$\n-trap \"rm -fr $tmp-*\" 0 1 2 3 15\n+trap \"rm -fr $tmp-*;exit\" 0 1 2 3 15\n tmpdir=$tmp-d\n \n case \"$peek_repo\" in\ndiff --git a/git-reset.sh b/git-reset.sh\nindex 6c9e58a..1b6781f 100755\n--- a/git-reset.sh\n+++ b/git-reset.sh\n@@ -4,7 +4,7 @@ USAGE='[--mixed | --soft | --hard]  [<co\n . git-sh-setup\n \n tmp=${GIT_DIR}/reset.$$\n-trap 'rm -f $tmp-*' 0 1 2 3 15\n+trap 'rm -f $tmp-*;exit' 0 1 2 3 15\n \n reset_type=--mixed\n case \"$1\" in\n"},{"id":"15035","messageId":"BAYC1-PASMTP123903F6C83FFE0EDA6284AE110@CEZ.ICE","threadId":"3127","inReplyTo":"BAYC1-PASMTP10435A067270A659801A48AE110@CEZ.ICE","subject":"Re: git cherry unkillable","fromName":"sean","fromEmail":"seanlkml@sympatico.ca","sentAt":"2006-01-22T14:51:13Z","receivedAt":"2006-01-22T14:51:13Z","isPatch":false,"sender":{"key":"seanlkml@sympatico.ca","avatar":"https://gravatar.com/avatar/f92923f54fc08c401fc59b71829d4b89e9b8087fbba45ff87c82e6a83aee02ae?d=mp&s=160"},"body":"On Sun, 22 Jan 2006 06:39:04 -0500\nsean <seanlkml@sympatico.ca> wrote:\n\n> The attached patch works for me but i'm concerned about it a bit.  \n\nBelow is a better version that doesn't obscure the proper exit value in the normal\ncase and exits with 1 if interrupted by the user.   It also ensures that the cleanup\nisn't executed twice when the script is interrupted.\n\nHowever, for Bash (at least) none of this is necessary; all the traps could just \nbe changed to only trap 0 and the cleanup will be executed for all cases.   However,\nI don't know how compatible that is with other shells.   If other shells behave\nthe same, the best fix is just to strip the 1,2,3 and 15 from each of the existing\ntrap lines and not bother with the patch given below.\n\nSean\n\n\ndiff --git a/git-cherry.sh b/git-cherry.sh\nindex 1a62320..0b2ef1f 100755\n--- a/git-cherry.sh\n+++ b/git-cherry.sh\n@@ -49,7 +49,8 @@ ours=`git-rev-list $ours ^$limit` || exi\n tmp=.cherry-tmp$$\n patch=$tmp-patch\n mkdir $patch\n-trap \"rm -rf $tmp-*\" 0 1 2 3 15\n+trap \"rm -rf $tmp-*\" 0\n+trap \"exit 1\" 1 2 3 15\n \n _x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'\n _x40=\"$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40\"\ndiff --git a/git-format-patch.sh b/git-format-patch.sh\nindex 7e67c4e..6ba6339 100755\n--- a/git-format-patch.sh\n+++ b/git-format-patch.sh\n@@ -77,7 +77,8 @@ tt)\n esac\n \n tmp=.tmp-series$$\n-trap 'rm -f $tmp-*' 0 1 2 3 15\n+trap \"rm -f $tmp-*\" 0\n+trap \"exit 1\" 1 2 3 15\n \n series=$tmp-series\n commsg=$tmp-commsg\ndiff --git a/git-ls-remote.sh b/git-ls-remote.sh\nindex f699268..7dc224b 100755\n--- a/git-ls-remote.sh\n+++ b/git-ls-remote.sh\n@@ -38,7 +38,8 @@ peek_repo=\"$(get_remote_url \"$@\")\"\n shift\n \n tmp=.ls-remote-$$\n-trap \"rm -fr $tmp-*\" 0 1 2 3 15\n+trap \"rm -rf $tmp-*\" 0\n+trap \"exit 1\" 1 2 3 15\n tmpdir=$tmp-d\n \n case \"$peek_repo\" in\ndiff --git a/git-reset.sh b/git-reset.sh\nindex 6c9e58a..166b635 100755\n--- a/git-reset.sh\n+++ b/git-reset.sh\n@@ -4,7 +4,8 @@ USAGE='[--mixed | --soft | --hard]  [<co\n . git-sh-setup\n \n tmp=${GIT_DIR}/reset.$$\n-trap 'rm -f $tmp-*' 0 1 2 3 15\n+trap \"rm -f $tmp-*\" 0\n+trap \"exit 1\" 1 2 3 15\n \n reset_type=--mixed\n case \"$1\" in\n"},{"id":"15036","messageId":"200601221801.29769.arvidjaar@mail.ru","threadId":"3127","inReplyTo":"BAYC1-PASMTP10435A067270A659801A48AE110@CEZ.ICE","subject":"Re: git cherry unkillable","fromName":"Andrey Borzenkov","fromEmail":"arvidjaar@mail.ru","sentAt":"2006-01-22T15:01:23Z","receivedAt":"2006-01-22T15:01:23Z","isPatch":false,"sender":{"key":"arvidjaar@mail.ru","avatar":null},"body":"-----BEGIN PGP SIGNED MESSAGE-----\nHash: SHA1\n\nOn Sunday 22 January 2006 14:39, sean wrote:\n>\n> The attached patch works for me \n\nack at least for git-cherry\n\n> but i'm concerned about it a bit.  With \n> this patch it looks like the signal handler is executed twice; once as\n> normal and a second time in response to the added \"exit\" statement.   By\n> adding \";trap - 0;exit\" it is only executed once, but i'm not sure how\n> universal that is, and letting it run twice shouldn't be a big deal anyway.\n>\n\nwhy not\n\ntrap \"rm -rf $tmp-*\" 0\ntrap \"exit\" 1 2 3 15\n\n?\n\n- -andrey\n-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1.4.2 (GNU/Linux)\n\niD8DBQFD055JR6LMutpd94wRAn06AJ0RrLXwND67hvhRrSeaQvUjgrfGrACeK1cs\nJA0jLNs5/8FPwpZqzKRd3eo=\n=8QbF\n-----END PGP SIGNATURE-----\n"},{"id":"15037","messageId":"200601221821.54461.arvidjaar@mail.ru","threadId":"3127","inReplyTo":"BAYC1-PASMTP123903F6C83FFE0EDA6284AE110@CEZ.ICE","subject":"Re: git cherry unkillable","fromName":"Andrey Borzenkov","fromEmail":"arvidjaar@mail.ru","sentAt":"2006-01-22T15:21:53Z","receivedAt":"2006-01-22T15:21:53Z","isPatch":false,"sender":{"key":"arvidjaar@mail.ru","avatar":null},"body":"-----BEGIN PGP SIGNED MESSAGE-----\nHash: SHA1\n\nOn Sunday 22 January 2006 17:51, sean wrote:\n> On Sun, 22 Jan 2006 06:39:04 -0500\n>\n> sean <seanlkml@sympatico.ca> wrote:\n> > The attached patch works for me but i'm concerned about it a bit.\n>\n> Below is a better version that doesn't obscure the proper exit value in the\n> normal case and exits with 1 if interrupted by the user.   It also ensures\n> that the cleanup isn't executed twice when the script is interrupted.\n>\n> However, for Bash (at least) none of this is necessary; all the traps could\n> just be changed to only trap 0 and the cleanup will be executed for all\n> cases.   However, I don't know how compatible that is with other shells.  \n> If other shells behave the same, the best fix is just to strip the 1,2,3\n> and 15 from each of the existing trap lines and not bother with the patch\n> given below.\n>\n\nthis patch fails on zsh; trap 0 never executed after signal (SIGINT to be \nsure) is caught:\n\n#!/bin/zsh\n\ntrap \"exit 0\" 1 2 3 15\ntrap \"echo  exiting\" 0\n\nsleep 100000000\n\n{pts/0}% /tmp/timout.zsh ^C\n{pts/0}% \n\n- -andrey\n\n> Sean\n>\n>\n> diff --git a/git-cherry.sh b/git-cherry.sh\n> index 1a62320..0b2ef1f 100755\n> --- a/git-cherry.sh\n> +++ b/git-cherry.sh\n> @@ -49,7 +49,8 @@ ours=`git-rev-list $ours ^$limit` || exi\n>  tmp=.cherry-tmp$$\n>  patch=$tmp-patch\n>  mkdir $patch\n> -trap \"rm -rf $tmp-*\" 0 1 2 3 15\n> +trap \"rm -rf $tmp-*\" 0\n> +trap \"exit 1\" 1 2 3 15\n>\n>  _x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'\n>  _x40=\"$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40\"\n> diff --git a/git-format-patch.sh b/git-format-patch.sh\n> index 7e67c4e..6ba6339 100755\n> --- a/git-format-patch.sh\n> +++ b/git-format-patch.sh\n> @@ -77,7 +77,8 @@ tt)\n>  esac\n>\n>  tmp=.tmp-series$$\n> -trap 'rm -f $tmp-*' 0 1 2 3 15\n> +trap \"rm -f $tmp-*\" 0\n> +trap \"exit 1\" 1 2 3 15\n>\n>  series=$tmp-series\n>  commsg=$tmp-commsg\n> diff --git a/git-ls-remote.sh b/git-ls-remote.sh\n> index f699268..7dc224b 100755\n> --- a/git-ls-remote.sh\n> +++ b/git-ls-remote.sh\n> @@ -38,7 +38,8 @@ peek_repo=\"$(get_remote_url \"$@\")\"\n>  shift\n>\n>  tmp=.ls-remote-$$\n> -trap \"rm -fr $tmp-*\" 0 1 2 3 15\n> +trap \"rm -rf $tmp-*\" 0\n> +trap \"exit 1\" 1 2 3 15\n>  tmpdir=$tmp-d\n>\n>  case \"$peek_repo\" in\n> diff --git a/git-reset.sh b/git-reset.sh\n> index 6c9e58a..166b635 100755\n> --- a/git-reset.sh\n> +++ b/git-reset.sh\n> @@ -4,7 +4,8 @@ USAGE='[--mixed | --soft | --hard]  [<co\n>  . git-sh-setup\n>\n>  tmp=${GIT_DIR}/reset.$$\n> -trap 'rm -f $tmp-*' 0 1 2 3 15\n> +trap \"rm -f $tmp-*\" 0\n> +trap \"exit 1\" 1 2 3 15\n>\n>  reset_type=--mixed\n>  case \"$1\" in\n-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1.4.2 (GNU/Linux)\n\niD8DBQFD06MSR6LMutpd94wRApgAAJ0e0AUIS83XTa4BA1rEY1XriHKZmQCgnXZd\n1sElZOLAgyuxgi3EHiaMGFc=\n=xwjP\n-----END PGP SIGNATURE-----\n"},{"id":"15038","messageId":"BAYC1-PASMTP03EC255443CA14D57D82F6AE110@CEZ.ICE","threadId":"3127","inReplyTo":"200601221821.54461.arvidjaar@mail.ru","subject":"Re: git cherry unkillable","fromName":"sean","fromEmail":"seanlkml@sympatico.ca","sentAt":"2006-01-22T15:32:04Z","receivedAt":"2006-01-22T15:32:04Z","isPatch":false,"sender":{"key":"seanlkml@sympatico.ca","avatar":"https://gravatar.com/avatar/f92923f54fc08c401fc59b71829d4b89e9b8087fbba45ff87c82e6a83aee02ae?d=mp&s=160"},"body":"On Sun, 22 Jan 2006 18:21:53 +0300\nAndrey Borzenkov <arvidjaar@mail.ru> wrote:\n\n> this patch fails on zsh; trap 0 never executed after signal (SIGINT to be \n> sure) is caught:\n> \n> #!/bin/zsh\n> \n> trap \"exit 0\" 1 2 3 15\n> trap \"echo  exiting\" 0\n> \n> sleep 100000000\n> \n> {pts/0}% /tmp/timout.zsh ^C\n> {pts/0}% \n> \n\nDamn, would be so much nicer to get this stuff out of shell scripts.   Anyway,\nyour discovery kills the idea of being able to just ignore the higher signal\ntraps...   The following implements the same idea as my second patch\nin hopefully a slightly more cross-shell compatible way;  it works on bash\nand zsh at least.\n\ndiff --git a/git-cherry.sh b/git-cherry.sh\nindex 1a62320..686210b 100755\n--- a/git-cherry.sh\n+++ b/git-cherry.sh\n@@ -49,7 +49,8 @@ ours=`git-rev-list $ours ^$limit` || exi\n tmp=.cherry-tmp$$\n patch=$tmp-patch\n mkdir $patch\n-trap \"rm -rf $tmp-*\" 0 1 2 3 15\n+trap \"rm -rf $tmp-*\" 0\n+trap \"kill -0 $$\" 1 2 3 15\n \n _x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'\n _x40=\"$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40\"\ndiff --git a/git-format-patch.sh b/git-format-patch.sh\nindex 7e67c4e..9f93bbb 100755\n--- a/git-format-patch.sh\n+++ b/git-format-patch.sh\n@@ -77,7 +77,8 @@ tt)\n esac\n \n tmp=.tmp-series$$\n-trap 'rm -f $tmp-*' 0 1 2 3 15\n+trap \"rm -f $tmp-*\" 0\n+trap \"kill -0 $$\" 1 2 3 15\n \n series=$tmp-series\n commsg=$tmp-commsg\ndiff --git a/git-ls-remote.sh b/git-ls-remote.sh\nindex f699268..0cd1f07 100755\n--- a/git-ls-remote.sh\n+++ b/git-ls-remote.sh\n@@ -38,7 +38,8 @@ peek_repo=\"$(get_remote_url \"$@\")\"\n shift\n \n tmp=.ls-remote-$$\n-trap \"rm -fr $tmp-*\" 0 1 2 3 15\n+trap \"rm -rf $tmp-*\" 0\n+trap \"kill -0 $$\" 1 2 3 15\n tmpdir=$tmp-d\n \n case \"$peek_repo\" in\ndiff --git a/git-reset.sh b/git-reset.sh\nindex 6c9e58a..597b36e 100755\n--- a/git-reset.sh\n+++ b/git-reset.sh\n@@ -4,7 +4,8 @@ USAGE='[--mixed | --soft | --hard]  [<co\n . git-sh-setup\n \n tmp=${GIT_DIR}/reset.$$\n-trap 'rm -f $tmp-*' 0 1 2 3 15\n+trap \"rm -f $tmp-*\" 0\n+trap \"kill -0 $$\" 1 2 3 15\n \n reset_type=--mixed\n case \"$1\" in\n"},{"id":"15039","messageId":"BAYC1-PASMTP02221D60BC2E89DF618E0AAE110@CEZ.ICE","threadId":"3127","inReplyTo":"BAYC1-PASMTP03EC255443CA14D57D82F6AE110@CEZ.ICE","subject":"Re: git cherry unkillable","fromName":"sean","fromEmail":"seanlkml@sympatico.ca","sentAt":"2006-01-22T15:48:50Z","receivedAt":"2006-01-22T15:48:50Z","isPatch":false,"sender":{"key":"seanlkml@sympatico.ca","avatar":"https://gravatar.com/avatar/f92923f54fc08c401fc59b71829d4b89e9b8087fbba45ff87c82e6a83aee02ae?d=mp&s=160"},"body":"On Sun, 22 Jan 2006 10:32:04 -0500\nsean <seanlkml@sympatico.ca> wrote:\n\n> Damn, would be so much nicer to get this stuff out of shell scripts.   Anyway,\n> your discovery kills the idea of being able to just ignore the higher signal\n> traps...   The following implements the same idea as my second patch\n> in hopefully a slightly more cross-shell compatible way;  it works on bash\n> and zsh at least.\n\nOoops, not even close on that attempt :o/   Here's a version that really does\nwork on zsh and bash; and should work on all shells.\n\nSean\n\ndiff --git a/git-cherry.sh b/git-cherry.sh\nindex 1a62320..4925f1f 100755\n--- a/git-cherry.sh\n+++ b/git-cherry.sh\n@@ -49,7 +49,9 @@ ours=`git-rev-list $ours ^$limit` || exi\n tmp=.cherry-tmp$$\n patch=$tmp-patch\n mkdir $patch\n-trap \"rm -rf $tmp-*\" 0 1 2 3 15\n+cleanup() { rm -rf $tmp-*; }\n+trap cleanup 0\n+trap \"cleanup;trap 0;exit 1\" 1 2 3 15\n \n _x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'\n _x40=\"$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40\"\ndiff --git a/git-format-patch.sh b/git-format-patch.sh\nindex 7e67c4e..574a79c 100755\n--- a/git-format-patch.sh\n+++ b/git-format-patch.sh\n@@ -77,7 +77,9 @@ tt)\n esac\n \n tmp=.tmp-series$$\n-trap 'rm -f $tmp-*' 0 1 2 3 15\n+cleanup() { rm -f $tmp-*; }\n+trap cleanup 0\n+trap \"cleanup;trap 0;exit 1\" 1 2 3 15\n \n series=$tmp-series\n commsg=$tmp-commsg\ndiff --git a/git-ls-remote.sh b/git-ls-remote.sh\nindex f699268..0259a88 100755\n--- a/git-ls-remote.sh\n+++ b/git-ls-remote.sh\n@@ -38,7 +38,9 @@ peek_repo=\"$(get_remote_url \"$@\")\"\n shift\n \n tmp=.ls-remote-$$\n-trap \"rm -fr $tmp-*\" 0 1 2 3 15\n+cleanup() { rm -rf $tmp-*; }\n+trap cleanup 0\n+trap \"cleanup;trap 0;exit 1\" 1 2 3 15\n tmpdir=$tmp-d\n \n case \"$peek_repo\" in\ndiff --git a/git-reset.sh b/git-reset.sh\nindex 6c9e58a..3336690 100755\n--- a/git-reset.sh\n+++ b/git-reset.sh\n@@ -4,7 +4,9 @@ USAGE='[--mixed | --soft | --hard]  [<co\n . git-sh-setup\n \n tmp=${GIT_DIR}/reset.$$\n-trap 'rm -f $tmp-*' 0 1 2 3 15\n+cleanup() { rm -f $tmp-*; }\n+trap cleanup 0\n+trap \"cleanup;trap 0;exit 1\" 1 2 3 15\n \n reset_type=--mixed\n case \"$1\" in\n"}]}