diff --git a/usr.sbin/bsdinstall/scripts/pkgbase.in b/usr.sbin/bsdinstall/scripts/pkgbase.in --- a/usr.sbin/bsdinstall/scripts/pkgbase.in +++ b/usr.sbin/bsdinstall/scripts/pkgbase.in @@ -23,18 +23,6 @@ return output:match("(.-)\n$") or output end -local function prompt_yn(question) - while true do - io.write(question .. " (y/n) ") - local input = io.read() - if input == "y" or input == "Y" then - return true - elseif input == "n" or input == "N" then - return false - end - end -end - local function append_list(list, other) for _, item in ipairs(other) do table.insert(list, item) @@ -73,6 +61,18 @@ return exit_code, output end +-- Prompts the user for a yes/no answer to the given question using bsddialog +-- Returns true if the user answers yes and false if the user answers no. +local function prompt_yn(question) + local exit_code = bsddialog({ + "--yesno", + "--disable-esc", + question, + 0, 0, -- autosize + }) + return exit_code == 0 +end + -- Creates a dialog for component selection mirroring the -- traditional tarball component selection dialog. local function select_components(components, options) @@ -253,7 +253,6 @@ while not os.execute(pkg .. "update") do if not prompt_yn("Updating repositories failed, try again?") then - print("Canceled") os.exit(1) end end @@ -262,7 +261,6 @@ while not os.execute(pkg .. "install -U -F -y -r FreeBSD-base " .. packages) do if not prompt_yn("Fetching packages failed, try again?") then - print("Canceled") os.exit(1) end end