Subject: [bug#70148] [PATCH v2] guix-install.sh: Add unique requirement for sysv init system

From: Richard Sent <[email-masked]>
Date: Sun, 02 Jun 2024 10:33:56 -0400

Hi Ludo!

Ludovic Courtès <[email-masked]> writes:

> ‘local’, [[, and arrays are probably Bash-specific.  However this is a
> #!/bin/sh script, and some systems such as Debian use Dash as /bin/sh.
> So I’m afraid the script would break on such systems.
>
> WDYT?  Do you think we can avoid those features?

Right, I did notice that. A strictly 100% POSIX-compliant shell doesn't
support local, arrays, or [[]] constructs. From my understanding Dash
supports 1 and /maybe/ 3, but not 2.

However, the script already contains provisions to enter bash even if launched
using a POSIX-complaint shell. See this at the beginning:

--8<---------------cut here---------------start------------->8---
if [ "x$BASH_VERSION" = "x" ]
then
    exec bash "$0" "$@"
fi
--8<---------------cut here---------------end--------------->8---

This construct is a little bit odd to me. At the time it was added ( by
you ;) ) because /usr/bin/env did not exist on Guix System [1], but
that's been added since [2]. Perhaps we should change the shebang to
#!/usr/bin/env bash.

(Also looks like the comment you wrote re. bash was spliced away from
the code.)

--8<---------------cut here---------------start------------->8---
# 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
.......
if [ "x$BASH_VERSION" = "x" ]
.......
--8<---------------cut here---------------end--------------->8---

The script is already using all 3 of these constructs too.

[1]: https://issues.guix.gnu.org/34279
[2]: https://issues.guix.gnu.org/35910

-- 
Take it easy,
Richard Sent
Making my computer weirder one commit at a time.