[bug#74962,2/3] etc/guix-install.sh: Explicit shebang to use /usr/bin/env.
Commit Message
Having an explicit shebang tells something useful: we depend on Bash. Tools
such as shellcheck make use of it. The original technical reason for avoiding
/usr/bin/env is no more (Guix System lacking it).
* etc/guix-install.sh: Adjust shebang. Remove conditional 'exec bash' further
block below.
Change-Id: I3c92a9e58fe11610dfbf74dbbd4b1ac8852abcf0
---
etc/guix-install.sh | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)
Comments
Maxim Cournoyer writes:
Hi Maxim,
> * etc/guix-install.sh: Adjust shebang. Remove conditional 'exec bash' further
> block below.
>
> Change-Id: I3c92a9e58fe11610dfbf74dbbd4b1ac8852abcf0
> ---
> etc/guix-install.sh | 15 ++++-----------
> 1 file changed, 4 insertions(+), 11 deletions(-)
>
> diff --git a/etc/guix-install.sh b/etc/guix-install.sh
> index f07b2741bb..481eb6f12a 100755
[..]
> -if [ "x$BASH_VERSION" = "x" ]
> -then
> - exec bash "$0" "$@"
> -fi
> -
+1 for the shebang but I think we want to keep this for people running:
sh install.sh, eg on Debian where sh is dash?
Greetings,
Janneke
Hi,
Janneke Nieuwenhuizen <janneke@gnu.org> writes:
> Maxim Cournoyer writes:
>
> Hi Maxim,
>
>> * etc/guix-install.sh: Adjust shebang. Remove conditional 'exec bash' further
>> block below.
>>
>> Change-Id: I3c92a9e58fe11610dfbf74dbbd4b1ac8852abcf0
>> ---
>> etc/guix-install.sh | 15 ++++-----------
>> 1 file changed, 4 insertions(+), 11 deletions(-)
>>
>> diff --git a/etc/guix-install.sh b/etc/guix-install.sh
>> index f07b2741bb..481eb6f12a 100755
> [..]
>> -if [ "x$BASH_VERSION" = "x" ]
>> -then
>> - exec bash "$0" "$@"
>> -fi
>> -
>
> +1 for the shebang but I think we want to keep this for people running:
> sh install.sh, eg on Debian where sh is dash?
Hm. Good point. I'll restore it in a v4, but I'll give it some time
before I do, so as to avoid sending yet another series in a short time.
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/usr/bin/env bash
# GNU Guix --- Functional package management for GNU
# Copyright © 2017 sharlatan <sharlatanus@gmail.com>
# Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
@@ -9,7 +9,7 @@
# Copyright © 2020 Daniel Brooks <db48x@db48x.net>
# Copyright © 2021 Jakub Kądziołka <kuba@kadziolka.net>
# Copyright © 2021 Chris Marusich <cmmarusich@gmail.com>
-# Copyright © 2021, 2022, 2023 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+# Copyright © 2021, 2022, 2023, 2024 Maxim Cournoyer <maxim.cournoyer@gmail.com>
# Copyright © 2022 Prafulla Giri <prafulla.giri@protonmail.com>
# Copyright © 2023 Andrew Tropin <andrew@trop.in>
# Copyright © 2020 David A. Redick <david.a.redick@gmail.com>
@@ -31,10 +31,8 @@
#
# You should have received a copy of the GNU General Public License
# along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
-
-# We require Bash but for portability we'd rather not use /bin/bash or
-# /usr/bin/env in the shebang, hence this hack.
-
+#
+#
# Environment variables
#
# GUIX_BINARY_FILE_NAME
@@ -50,11 +48,6 @@
# installation required the user to extract Guix packs under /gnu to
# satisfy its dependencies.
-if [ "x$BASH_VERSION" = "x" ]
-then
- exec bash "$0" "$@"
-fi
-
set -eo pipefail
[ "$UID" -eq 0 ] || { echo "This script must be run as root."; exit 1; }