01.04.2023 13:33, Mikhail пишет:
> Currently default answer for the question is 'yes', which is not true
> for install case, but correct for upgrade one.

True for sysupgrade(8) (at least with default /home/_sysupgrade), but
certainly not true in general for every update scenario.

> Changing default answer depending on the mode of the installer looks
> like a good approach. Idea by Christian (naddy@), implementation and
> testing are mine.

It is not yet clear to me which default would benefit most installer
scenarios.

>  install_disk() {
> -     if ! ask_yn "Is the disk partition already mounted?" yes; then
> +     local _answer
> +
> +     # In installation mode installer doesn't automount partitions

You imply that during upgrade partitions are automounted.
That's true for partitions in the root disk's /etc/fstab only.

But sets can be anywhere on any disk, which still have to be mounted
by answering 'no' to this question.

> +     [[ $MODE == install ]] || _answer=yes

Using == with && would be one less logical negation.

> +
> +     if ! ask_yn "Is the disk partition already mounted?" $_answer; then

$_answer may be unset, but you still pass it and thus rely on ask_yn()'s
default 'no' answer.

I'd just default-initialise up front and flip if conditions are met.
This should read and reflect your intentions more clearly:

        local _answer=no

        [[ $MODE == upgrade ]] && _answer=yes

>               ask_which "disk" "contains the $MODE media" \
>                       '$(bsort $(get_dkdevs))' \
>                       '$(get_dkdevs_uninitialized)'
>

Reply via email to