From 55abcbb8f60e1afe3af0133a6ff0e9dedc6df1b7 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Tue, 7 Feb 2023 21:38:24 -0500 Subject: minstall: check 5 times for an answer to the elevation prompt The user might press enter by accident and miss the message. --- mesonbuild/minstall.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/mesonbuild/minstall.py b/mesonbuild/minstall.py index a645960..698feef 100644 --- a/mesonbuild/minstall.py +++ b/mesonbuild/minstall.py @@ -566,10 +566,13 @@ class Installer: if rootcmd is not None: print('Installation failed due to insufficient permissions.') - ans = input(f'Attempt to use {rootcmd} to gain elevated privileges? [y/n] ') - if ans not in {'y', 'n'}: + for attempt in range(5): + ans = input(f'Attempt to use {rootcmd} to gain elevated privileges? [y/n] ') + if ans in {'y', 'n'}: + break + else: raise MesonException('Answer not one of [y/n]') - elif ans == 'y': + if ans == 'y': os.execlp(rootcmd, rootcmd, sys.executable, main_file, *sys.argv[1:], '-C', os.getcwd(), '--no-rebuild') raise -- cgit v1.1