From 20de9cbc891d9d0a93d99ac3e251ac286daff5a0 Mon Sep 17 00:00:00 2001 From: "Owen W. Taylor" Date: Sat, 5 Jun 2010 14:54:40 -0400 Subject: When prompting, loop, don't default on unknown inputs Rather than taking empty or unknown input as a "no", just reprompt. I don't think the default value is obvious enough for people to actually figure it out and rely on it, so we might as well add extra robustness to accidental input. --- git-bz | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/git-bz b/git-bz index b73fe52..7868466 100755 --- a/git-bz +++ b/git-bz @@ -711,11 +711,15 @@ def expand_abbreviation(abbrev, l): raise ValueError("No unique abbreviation expansion") def prompt(message): - # Using print here could result in Python adding a stray space - # before the next print - sys.stdout.write(message + " [yn] ") - line = sys.stdin.readline().strip() - return line == 'y' or line == 'Y' + while True: + # Using print here could result in Python adding a stray space + # before the next print + sys.stdout.write(message + " [yn] ") + line = sys.stdin.readline().strip() + if line == 'y' or line == 'Y': + return True + elif line == 'n' or line == 'N': + return False def die(message): print >>sys.stderr, message -- cgit v1.2.3