summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOwen W. Taylor <otaylor@fishsoup.net>2010-06-05 14:54:40 -0400
committerOwen W. Taylor <otaylor@fishsoup.net>2010-06-05 14:54:40 -0400
commit20de9cbc891d9d0a93d99ac3e251ac286daff5a0 (patch)
tree075602c79165708b32dc812f8cf4977368248f67
parent88a2b9047e61c784c2c1e78c3d2434eaaebc8bd0 (diff)
downloadgit-bz-20de9cbc891d9d0a93d99ac3e251ac286daff5a0.tar.gz
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.
-rwxr-xr-xgit-bz14
1 files 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