guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bug#58417: Installer script no longer works with `yes` utility


From: Maxim Cournoyer
Subject: Re: bug#58417: Installer script no longer works with `yes` utility
Date: Tue, 11 Oct 2022 15:29:53 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux)

Hi,

Tobias Geerinckx-Rice <me@tobias.gr> writes:

> [Shunted to guix-devel@]
>
> Jonas Freimuth 写道:
>> bash -c 'yes | bash guix-install.sh'
>
> While this happens to work (again) now, that doesn't mean it always
> will or should be considered supported.
>
> We should reserve the right to ask future questions to which the
> safe/sane/common answer is ‘no’, without phrasing it awkwardly just to
> make an unthinking stream of ‘y’s happy.
>
>  $ guix-install.sh
>
>  Would you like to NOT enable the Cool Experimental Feature?
>  (DANGER) [Y/n]
>
> Conversely, I'd like to add a comment that does commit to always
> keeping ‘yes '' | bash guix-install.sh’ working, assuming there was no
> other input or detected issues.  Also nice for humans in a hurry.
>
> Does that seem unreasonable to anyone?

To the contrary, that seems pretty reasonable.  You may be interested in
this version of a biased prompt, gracefully shared by Earnestly from
#bash:

--8<---------------cut here---------------start------------->8---
confirm() {
    local -l reply
    local prompt bias=$1
    shift

    case $bias in
        yes) prompt=Y/n ;;
        no)  prompt=y/N
    esac

    # shellcheck disable=SC2059
    printf -- "\033[1m* $1 [$prompt]\033[0m " "${@:2}"
    read -r reply

    case $bias in
        yes) [[ $reply = y || ! $reply ]] ;;
        no)  [[ $reply = y ]]
    esac
}
--8<---------------cut here---------------end--------------->8---

The first arguments is the default argument (yes or no).  The rest works
the same (but they used printf to format things).  We can adapt our
version with that.

If you make the change you'll want to write a news so that 'yes' users
can transition to "yes ''".

-- 
Thanks,
Maxim



reply via email to

[Prev in Thread] Current Thread [Next in Thread]