summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/vyos/util.py23
1 files changed, 13 insertions, 10 deletions
diff --git a/python/vyos/util.py b/python/vyos/util.py
index 699f05892..ab5029c92 100644
--- a/python/vyos/util.py
+++ b/python/vyos/util.py
@@ -554,16 +554,19 @@ def ask_yes_no(question, default=False) -> bool:
from sys import stdout
default_msg = "[Y/n]" if default else "[y/N]"
while True:
- stdout.write("%s %s " % (question, default_msg))
- c = input().lower()
- if c == '':
- return default
- elif c in ("y", "ye", "yes"):
- return True
- elif c in ("n", "no"):
- return False
- else:
- stdout.write("Please respond with yes/y or no/n\n")
+ try:
+ stdout.write("%s %s " % (question, default_msg))
+ c = input().lower()
+ if c == '':
+ return default
+ elif c in ("y", "ye", "yes"):
+ return True
+ elif c in ("n", "no"):
+ return False
+ else:
+ stdout.write("Please respond with yes/y or no/n\n")
+ except EOFError:
+ stdout.write("\nPlease respond with yes/y or no/n\n")
def is_admin() -> bool: