Subject: Re: bug#40641: Building from git breaks when /bin/sh isn't bash

From: Maxim Cournoyer <[email-masked]>
Date: Sun, 10 Jul 2022 00:56:08 -0400

Hello,

"pelzflorian (Florian Pelz)" <[email-masked]> writes:

> Wait wait Maxim, the discussion was that
> "B. Wilson" <[email-masked]> proposed
>> [PATCH] build: Let make use its hard-coded default shell
>  > To: [email-masked]
>>
>  > * configure.ac: Set AM_SUBST_NOTMAKE([SHELL])
>  > +# Use make's hard-coded default shell. The make in a guix profile
>  > +# defaults to the Right Thing, e.g. $GUIX_ENVIRONMENT/bin/sh
>> +AM_SUBST_NOTMAKE([SHELL])
>
> Then Maxim Cournoyer <[email-masked]> writes:
>> This seems odd to me. Perhaps it'd be cleaner to detect which shell is
>  > used at configure time to detect when /bin/sh != Bash, and warn that if
>  > there are issues, the user should set the SHELL variable to Bash.
>
> [email-masked] writes:
>> Excellent. I agree it's probably not worth POSIXifying the scripts. Forcing
>> make to default to guix's bash seems like the right approach IMHO, so +1 for
>> that fix.
>
> I think we’re not on the same page.  Is AM_SUBST_NOTMAKE([SHELL]) really
> problematic?  Is seems like there is a legitimate use-case that foreign
> distro users with /bin/sh = dash would want “guix shell -D guix -- make”
> to just work without workaround?  We could use elaexuotee’s
> AM_SUBST_NOTMAKE([SHELL]) patch, could we not?

Indeed, I had misunderstood, apologies.  I've read the Autoconf/Automake
Info manuals about AM_SUBST and AM_SUBST_NOTMAKE, but I don't have a
clear understanding of the mechanisms involved.

from info '(autoconf) config.status Invocation':

 -- Variable: CONFIG_SHELL
     The shell with which to run ‘configure’.  It must be
     Bourne-compatible, and the absolute name of the shell should be
     passed.  The default is a shell that supports ‘LINENO’ if
     available, and ‘/bin/sh’ otherwise.

So it appears to me that by default, it'd look for a shell that supports
LINENO if available, such as /bin/bash or something else?  E.g., not use
the user's SHELL environment variable directly, but that can be
overridden with CONFIG_SHELL.

Using AC_SUBST_NOTMAKE([SHELL]) would cause SHELL to be substituted in
the build system files but prevent setting Make variables such as SHELL
= '/bin/...' in generated Makefiles...  how do that end up causing the
Guix-provided Make to use its own "known" shell?

It seems to me that a potential pitfall would be that by adding
AC_SUBST_NOTMAKE([SHELL]), we'd change the default behavior of Autoconf,
which is to honor CONFIG_SHELL and set the SHELL Make variable based on
that; it seems it could be simpler to document that users on systems
using a Bourne incompatible shell should set CONFIG_SHELL to a Bourne
compatible one to build Guix from sources.

Is someone able to explain how the suggested fix work in more details?

Thanks,

Maxim