On 2024-07-18 09:40, Zack Weinberg wrote:
> On Thu, Jul 18, 2024, at 5:09 AM, Tijl Coosemans wrote:
>> Automake 1.17 produces a warning for the use of \# ...
>
> For reference, the construct in question is
>
> subst = sed \
>       -e 's|@PACKAGE_VERSION[@]|$(PACKAGE_VERSION)|g' \
>       -e '1 s|^\#\!.*perl$$|\#\!$(PERL)|g' \
>       -e 's|@localstatedir[@]|$(localstatedir)|g' \
>         [etc]
[...]
> I could be wrong about this, but I don't think any implementation of Make
> pays _any_ attention to shell quotation in commands.  Therefore, no, this
> is not portable.

Note that there is only any problem at all because the # characters are
used in a make variable assignment.  If it was written literally into a
rule instead, for example:

  substitute:
        sed -e '1s|^#!.*perl$$|#!$(PERL)|g' ...

there is no portability problem, as # does not introduce a make comment
when it appears within the commands of a rule.

If the only reason for using a make variable is just to reduce typing
(because it's used in more than one rule) one simple option is to use
a configure-time substitution instead (totally untested):

  configure.ac:
    AC_SUBST([blargh], ['sed -e '\''1s|^#!.*perl|#!$(PERL)|'\'])
    AM_SUBST_NOTMAKE([blargh])

  Makefile.am:
    substitute:
        @blargh@ ...

Cheers,
  Nick

Reply via email to