[bug#33134,0/4,Refactor,0] Add auto yes/no switch to guix-install.sh
mbox series

Message ID 20181109041301.39042-1-s@ricketyspace.net
Headers show
Series
  • Add auto yes/no switch to guix-install.sh
Related show

Message

rsiddharth Nov. 9, 2018, 4:13 a.m. UTC
Thanks Danny, I've refactored the patch based on your feedack.

Danny Milosavljevic wrote:

>> +    # process -y / -n arg.
>> +    export AUTO_YN=${1:1:1}
>> +    if [ -z $AUTO_YN ]; then
>> +        export AUTO_YN=""
>> +    fi

> Why "export" ? Now all the child processes get it, making their environment
> different from before.  This makes parse_args have system-wide side effects.

Remove the `export`.

>> ...
>>  
>>  main()
>>  {
>> +    parse_args $@
>> +

> Should be
>
>   "$@"
>
>with quotes

Done.

>> ...
>> ...
>>  https://www.gnu.org/software/guix/
>>  EOF
>>      echo -n "Press return to continue..."
>> -    read -r  ANSWER
>> +    read -N 1 -r  ANSWER

> While it's nice for the interactive user, doesn't this break
>
>  yes | ./guix-install.sh
>
> because now it doesn't wait for the newline?

Yes, it would break `yes | ./guix-install.sh`. I've removed `-N 1` from the `read` statement.


>> -            *) _msg "Please answer yes or no.";
>> +            *) _msg "Please answer yes or no."; yn=""

> Does this make it conditionally interactive?  Would it be better to "exit 1" here?

When the user is running the script interactively and answers, say "Oui", we
arrive at the:

                 *) _msg "Please answer yes or no.";

case. After this, we go to the beginning of the loop:

                 [[ -n $yn ]] || read -p "Permit downloading pre-built package binaries from the project's build farms? (yes/no) " yn

Since $yn is "Oui" `[[ -n $yn ]]` will evaluate to true, the user won't be
prompted again, we'll go back to:

                 *) _msg "Please answer yes or no."

and this will repeat infinitely.

The `yn=""` was added:

                 *) _msg "Please answer yes or no."; yn=""

to reset the value of yn, so that `[[ -n $yn ]]` will evaluate to false and
the user will be prompted again for answer.

rsiddharth (4):
  guix-install.sh: Add parse_args.
  guix-install.sh: Update main.
  guix-install.sh: Update welcome.
  guix-install.sh: Update sys_authorize_build_farms.

 etc/guix-install.sh | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)