From 5a5dda14fd3d472680568f1792e9fbdb030f3995 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Wed, 22 May 2024 18:10:57 +0100 Subject: vyos.utils.io: T6385: handle keyboard interrupts in ask_yes_no and return False if the user interrupts the prompt with Ctrl-C --- python/vyos/utils/io.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/python/vyos/utils/io.py b/python/vyos/utils/io.py index a8c430f28..205210b66 100644 --- a/python/vyos/utils/io.py +++ b/python/vyos/utils/io.py @@ -72,6 +72,8 @@ def ask_yes_no(question, default=False) -> bool: stdout.write("Please respond with yes/y or no/n\n") except EOFError: stdout.write("\nPlease respond with yes/y or no/n\n") + except KeyboardInterrupt: + return False def is_interactive(): """Try to determine if the routine was called from an interactive shell.""" -- cgit v1.2.3