diff --git a/install.ps1 b/install.ps1 index a2992485..8440b3db 100644 --- a/install.ps1 +++ b/install.ps1 @@ -8,7 +8,7 @@ param( $ErrorActionPreference = "Stop" $defaultInstallUrl = "https://raw.githubusercontent.com/Abdess/retrobios/main/install.py" -$defaultInstallSha256 = "6622a88280f46e21e7fac0adce72973211461cb6dc4af9cd3c5c1be8dd3aa842" +$defaultInstallSha256 = "8cf8886b8332714c2a2bc690a831fa2dd4b42f6b9c19df63bc002383b3650c2e" $maximumInstallerBytes = 2MB $installerExit = 0 $installer = if ($PSScriptRoot) { Join-Path $PSScriptRoot "install.py" } else { $null } diff --git a/install.py b/install.py index 0ec3cfe1..329e7193 100644 --- a/install.py +++ b/install.py @@ -2562,9 +2562,14 @@ def installer_id() -> str: return "unknown" +# Answers that stop: every menu before this one taught q as quit. +_REFUSALS = ("n", "q", "quit", "exit", "stop", "abort") + + def _confirm(prompt: str) -> bool: - """Yes unless the answer starts with n.""" - return not _ask(prompt).lower().startswith("n") + """Yes unless the answer refuses: n, no, or one of the quit words.""" + answer = _ask(prompt).strip().lower() + return not (answer.startswith("n") or answer in _REFUSALS) def _print_plan(to_download: list[dict], bios_path: Path, term: Terminal) -> None: diff --git a/install.sh b/install.sh index c0488db0..4ff86fab 100755 --- a/install.sh +++ b/install.sh @@ -18,7 +18,7 @@ esac TEMP_INSTALLER="" TEMP_DIRECTORY="" DEFAULT_INSTALL_URL="https://raw.githubusercontent.com/Abdess/retrobios/main/install.py" -DEFAULT_INSTALL_SHA256="6622a88280f46e21e7fac0adce72973211461cb6dc4af9cd3c5c1be8dd3aa842" +DEFAULT_INSTALL_SHA256="8cf8886b8332714c2a2bc690a831fa2dd4b42f6b9c19df63bc002383b3650c2e" MAX_INSTALLER_BYTES=2097152 cleanup() { diff --git a/tests/test_install.py b/tests/test_install.py index 88bef060..574696e7 100644 --- a/tests/test_install.py +++ b/tests/test_install.py @@ -2433,5 +2433,18 @@ class RetroArchUwpIsFound(unittest.TestCase): self.assertIsNone(install._retroarch_uwp_system_dir()) + +class QuitMeansNoAtTheLastQuestion(unittest.TestCase): + """Every menu taught q as quit; at "Download 3.2 GB ...? [Y/n]" a q + started the download.""" + + def test_quit_words_refuse(self): + for answer, expected in (("q", False), ("quit", False), ("exit", False), + ("n", False), ("No", False), ("", True), ("y", True)): + with self.subTest(answer=answer), \ + unittest.mock.patch.object(install, "_ask", return_value=answer): + self.assertIs(install._confirm("? "), expected) + + if __name__ == "__main__": unittest.main()