Skip to content
Browse files

cmd/{index,save}: handle ctrl-c without printing a big exception trace.

It's not very exciting to look at a whole stack trace just because someone
hit ctrl-c, especially since that's designed to work fine.  Trim it down in
that case.
  • Loading branch information...
1 parent 035bad1 commit a05f66cb9b18729fd61d6dabf6d9d31ce7eda6ad @apenwarr apenwarr committed
Showing with 14 additions and 0 deletions.
  1. +2 −0 cmd/index-cmd.py
  2. +2 −0 cmd/save-cmd.py
  3. +10 −0 lib/bup/helpers.py
View
2 cmd/index-cmd.py
@@ -142,6 +142,8 @@ def hashgen(name):
git.check_repo_or_die()
indexfile = opt.indexfile or git.repo('bupindex')
+handle_ctrl_c()
+
if opt.check:
log('check: starting initial check.\n')
check_index(index.Reader(indexfile))
View
2 cmd/save-cmd.py
@@ -37,6 +37,8 @@
oldref = refname and git.read_ref(refname) or None
w = git.PackWriter()
+handle_ctrl_c()
+
def eatslash(dir):
if dir.endswith('/'):
View
10 lib/bup/helpers.py
@@ -284,3 +284,13 @@ def add_error(e):
def progress(s):
if istty:
log(s)
+
+
+def handle_ctrl_c():
+ oldhook = sys.excepthook
+ def newhook(exctype, value, traceback):
+ if exctype == KeyboardInterrupt:
+ log('Interrupted.\n')
+ else:
+ return oldhook(exctype, value, traceback)
+ sys.excepthook = newhook

0 comments on commit a05f66c

Please sign in to comment.
Something went wrong with that request. Please try again.