Hi,

Tobias Geerinckx-Rice <[email protected]> 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