Hi Bruno,

Bruno Haible via GNU coreutils Bug Reports <bug-coreutils@gnu.org>
writes:

> It looks like the 'speedgen' script, added in commit
> 357fda90d15fd3f7dba61e1ab322b183a48d0081, produces this invalid C code.
>
> With GNU sed:
>
> $ echo 100 | sed -e 's/^.*$/#  ifdef B&\n      case B&: return &;\n#  endif/'
> #  ifdef B100
>       case B100: return 100;
> #  endif
>
> With OpenBSD sed and Solaris sed:
>
> $ echo 100 | sed -e 's/^.*$/#  ifdef B&\n      case B&: return &;\n#  endif/'
> #  ifdef B100n      case B100: return 100;n#  endif
>
> The attached patch fixes it.

Good catch, I fixed something similar in git a few weeks ago [1]. From
the commit message:


    The OpenBSD 'sed' command does not support '\n' to represent newlines in
    sed expressions. This leads to the follow compiler error:
    
        In file included from builtin/help.c:15:
        ./config-list.h:282:18: error: use of undeclared identifier 'n'
                "gitcvs.dbUser",n       "gitcvs.dbPass",
                                ^
        1 error generated.
        gmake: *** [Makefile:2821: builtin/help.o] Error 1


Perhaps it is worth documenting somewhere? I think Autoconf's manual has
a section of shell portability gotchas.

Collin

[1] https://github.com/git/git/commit/db170e18262ed10e5e9b7f3cbca6a0ac43267b20



Reply via email to