Bruno Haible <br...@clisp.org> writes:

> Hi Po Lu,
>
>> Gnulib generates non-portable shell constructs, which interferes with
>> configuring Emacs on Solaris 10 using /bin/sh.
>> 
>> See
>> 
>>   https://lists.gnu.org/archive/html/bug-gnu-emacs/2023-04/msg01590.html
>
> Indeed, the Autoconf manual
> <https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.71/html_node/Limitations-of-Builtins.html>
> lists 'if ! command' as not working on Solaris 10.
>
>> Would this be a sufficient solution?  I've not had a chance to test it
>> yet.
>> 
>> 2023-04-26  Po Lu  <luang...@yahoo.com>
>> 
>>      * pygnulib/GLEmiter.py (GLEmiter.autoconfSnippets): Avoid
>>      non-portable Bourne shell construct.
>
> For the Python rewrite of gnulib-tool, that is exactly the right fix; thanks.
> For the original gnulib-tool, which is the one still recommended for now, see
> https://www.gnu.org/software/gnulib/manual/html_node/Invoking-gnulib_002dtool.html
>  ,
> we need the same change. I'm committing this:
>
>
> 2023-04-26  Po Lu  <luang...@yahoo.com>  (tiny change)
>             Bruno Haible  <br...@clisp.org>
>
>       gnulib-tool: For conditional dependencies, generate portable sh code.
>       * gnulib-tool (func_emit_autoconf_snippets): Avoid sh syntax
>       'if ! variable', that does not work with Solaris /bin/sh.
>       * pygnulib/GLEmiter.py (GLEmiter.autoconfSnippets): Likewise.
>
> diff --git a/gnulib-tool b/gnulib-tool
> index 5373333f74..74c395d9a4 100755
> --- a/gnulib-tool
> +++ b/gnulib-tool
> @@ -4731,7 +4731,7 @@ func_emit_autoconf_snippets ()
>            func_module_shellvar_name "$module"
>            echo "  $shellfunc ()"
>            echo '  {'
> -          echo "    if ! \$$shellvar; then"
> +          echo "    if \$$shellvar; then :; else"
>            func_emit_autoconf_snippet "      "
>            echo "      $shellvar=true"
>            deps=`func_get_dependencies $module | sed -e 
> "$sed_dependencies_without_conditions"`
> diff --git a/pygnulib/GLEmiter.py b/pygnulib/GLEmiter.py
> index 93f50b728c..dc46ba89e9 100644
> --- a/pygnulib/GLEmiter.py
> +++ b/pygnulib/GLEmiter.py
> @@ -283,7 +283,7 @@ class GLEmiter(object):
>                          shellvar = module.getShellVar()
>                          emit += '  %s ()\n' % shellfunc
>                          emit += '  {\n'
> -                        emit += '    if ! $%s; then\n' % shellvar
> +                        emit += '    if $%s; then :; else\n' % shellvar
>                          emit += self.autoconfSnippet(module, toplevel,
>                                                       disable_libtool, 
> disable_gettext, replace_auxdir, '      ')
>                          emit += '      %s=true\n' % shellvar

Thank you.

Reply via email to