When git am is called w/o arguments, w/o a patch on stdin and the user hits ctrl-c, it leaves behind a partially populated $dotest directory. After this commit, it emits usage when called w/o arguments and w/o a patch on stdin. Also ensure that $dotest is cleaned up if user manages to interupt mailsplit while it is processing input, but not if mailsplit exits non-zero due to error. Noticed by Sverre Rabbelier Signed-off-by: Jay Soffian <jaysoffian@xxxxxxxxx> --- Change from v1: don't remove $dotest if mailsplit exits non-zero git-am.sh | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) diff --git a/git-am.sh b/git-am.sh index b1c05c9..65285a0 100755 --- a/git-am.sh +++ b/git-am.sh @@ -254,10 +254,13 @@ else done shift fi - git mailsplit -d"$prec" -o"$dotest" -b -- "$@" > "$dotest/last" || { - rm -fr "$dotest" + test $# = 0 && test -t 0 && usage + trap 'rm -fr "$dotest"' 0 + git mailsplit -d"$prec" -o"$dotest" -b -- "$@" > "$dotest/last" || { + trap - 0 exit 1 } + trap - 0 # -s, -u, -k, --whitespace, -3, -C and -p flags are kept # for the resuming session after a patch failure. -- 1.6.1.224.gb56c -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html