[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#60069] [PATCH 2/2] guix-install.sh: Directly exit in case of errors
From: |
Maxim Cournoyer |
Subject: |
[bug#60069] [PATCH 2/2] guix-install.sh: Directly exit in case of errors in chk_require. |
Date: |
Wed, 14 Dec 2022 13:33:26 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) |
Hi,
Maxim Cournoyer <maxim.cournoyer@gmail.com> writes:
> Hi Tobias,
>
> Tobias Geerinckx-Rice <me@tobias.gr> writes:
>
>> Maxim Cournoyer 写道:
>>> - [ "${#warn}" -ne 0 ] &&
>>> - { _err "${ERR}Missing commands: ${warn[*]}.";
>>> - return 1; }
>>> - + [ "${#warn}" -ne 0 ] && die "Missing commands:
>>> ${warn[*]}."
>>> +
>>
>> I did not run this, but will it not itself trigger -e when the test
>> is false?
>
> This apparently falls in the special casing by Bash of what is
> considered a failure when using 'set -e'; here's a test:
>
> $ cat test.sh
> #!/usr/bin/env bash
>
> set -e
>
> [ false ] && echo "hey, we made it!"
>
> $ ./test.sh
> hey, we made it!
The above example was bogus and unnecessary; looking at it more closely,
the test would return true when the 'warn' array contains 1 or more
items (missing commands), which would cause the die command to be
invoked and the script to exit. The first test handling isn't modified,
so it'll chain though the second part the same as it does now.
I hope that's a better explanation.
--
Thanks,
Maxim
- [bug#60068] [PATCH 1/2] guix-install.sh: Add GUIX_ALLOW_OVERWRITE environment variable., Maxim Cournoyer, 2022/12/14
- [bug#60068] [PATCH 1/2] guix-install.sh: Add GUIX_ALLOW_OVERWRITE environment variable., Tobias Geerinckx-Rice, 2022/12/14
- [bug#60068] [PATCH v2 1/3] guix-install.sh: Add missing "useradd" command., Maxim Cournoyer, 2022/12/14
- [bug#60068] [PATCH v2 3/3] guix-install.sh: Directly exit in case of errors in chk_require., Maxim Cournoyer, 2022/12/14
- [bug#60068] bug#60069: [PATCH 2/2] guix-install.sh: Directly exit in case of errors in chk_require., Ludovic Courtès, 2022/12/15