diff options
author | Owen W. Taylor <otaylor@fishsoup.net> | 2010-06-05 14:54:40 -0400 |
---|---|---|
committer | Owen W. Taylor <otaylor@fishsoup.net> | 2010-06-05 14:54:40 -0400 |
commit | 20de9cbc891d9d0a93d99ac3e251ac286daff5a0 (patch) | |
tree | 075602c79165708b32dc812f8cf4977368248f67 | |
parent | 88a2b9047e61c784c2c1e78c3d2434eaaebc8bd0 (diff) | |
download | git-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-x | git-bz | 14 |
1 files changed, 9 insertions, 5 deletions
@@ -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 |