guix-install.sh: uses /bin/bash shebang

  • Done
  • quality assurance status badge
Details
3 participants
  • Claes Wallin (???)
  • Ludovic Courtès
  • Ricardo Wurmus
Owner
unassigned
Submitted by
Claes Wallin (???)
Severity
normal
C
C
Claes Wallin (???) wrote on 1 Feb 2019 16:35
(address . bug-guix@gnu.org)
CAGv_=Br6meZVGWf4-qNJ0P_f5W6_WOF-S2NsZ8mRdaJ4+Ey2gw@mail.gmail.com
This means ./guix-install.sh doesn't work on e.g. NixOS. :-)

Please use /usr/bin/env bash.

The manual workaround is obvious, but this is a thousand-papercuts bug.
L
L
Ludovic Courtès wrote on 4 Feb 2019 22:26
(name . Claes Wallin)(address . clacke@lysator.liu.se)(address . 34279@debbugs.gnu.org)
87lg2vp7o4.fsf@gnu.org
Hi,

Claes Wallin (???) <clacke@lysator.liu.se> skribis:

Toggle quote (4 lines)
> This means ./guix-install.sh doesn't work on e.g. NixOS. :-)
>
> Please use /usr/bin/env bash.

/usr/bin/env wouldn’t work on Guix System by default. :-)

What about something like this:
Toggle diff (24 lines)
diff --git a/etc/guix-install.sh b/etc/guix-install.sh
index 8eb5214049..dc8de2fe92 100755
--- a/etc/guix-install.sh
+++ b/etc/guix-install.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
# GNU Guix --- Functional package management for GNU
# Copyright © 2017 sharlatan <sharlatanus@gmail.com>
# Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
@@ -19,6 +19,13 @@
# 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.
+if [ "x$BASH_VERSION" = "x" ]
+then
+ exec bash "$0" "$@"
+fi
+
set -e
[ "$UID" -eq 0 ] || { echo "This script must be run as root."; exit 1; }
Thanks,
Ludo’.
R
R
Ricardo Wurmus wrote on 4 Feb 2019 22:56
(name . Ludovic Courtès)(address . ludo@gnu.org)
877eefi5fy.fsf@elephly.net
Ludovic Courtès <ludo@gnu.org> writes:

Toggle quote (10 lines)
> Hi,
>
> Claes Wallin (???) <clacke@lysator.liu.se> skribis:
>
>> This means ./guix-install.sh doesn't work on e.g. NixOS. :-)
>>
>> Please use /usr/bin/env bash.
>
> /usr/bin/env wouldn’t work on Guix System by default. :-)

“guix-install.sh” arguably would not primarily be executed on a Guix
system.

Toggle quote (8 lines)
> +# We require Bash but for portability we'd rather not use /bin/bash or
> +# /usr/bin/env in the shebang, hence this hack.
> +if [ "x$BASH_VERSION" = "x" ]
> +then
> + exec bash "$0" "$@"
> +fi
> +

Neat!

--
Ricardo
L
L
Ludovic Courtès wrote on 5 Feb 2019 12:04
(name . Claes Wallin)(address . clacke@lysator.liu.se)(address . 34279-done@debbugs.gnu.org)
87ftt2jy2b.fsf@gnu.org
Ludovic Courtès <ludo@gnu.org> skribis:

Toggle quote (23 lines)
> What about something like this:
>
> diff --git a/etc/guix-install.sh b/etc/guix-install.sh
> index 8eb5214049..dc8de2fe92 100755
> --- a/etc/guix-install.sh
> +++ b/etc/guix-install.sh
> @@ -1,4 +1,4 @@
> -#!/bin/bash
> +#!/bin/sh
> # GNU Guix --- Functional package management for GNU
> # Copyright © 2017 sharlatan <sharlatanus@gmail.com>
> # Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
> @@ -19,6 +19,13 @@
> # 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.
> +if [ "x$BASH_VERSION" = "x" ]
> +then
> + exec bash "$0" "$@"
> +fi

Pushed as f5fdc54d3a0845d0590c181d3bd6016f22765431.

Ludo’.
Closed
?
Your comment

This issue is archived.

To comment on this conversation send an email to 34279@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 34279
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch