Bruno Haible <bruno <at> clisp.org> writes: > Ah! The culprit is the --posix option that gnulib-tool adds: > > This looks like a bug to me: \\ expands to nothing. No way to produce a > backslash in the replacement.
I concur. > Can you confirm my interpretations? > > > POSIX says that \/ is not portable when / is not the delimiter. > > In addresses (selection of lines), certainly. But it the 's' command? I cannot find > the wording that says so. "The replacement string shall be scanned from beginning to end. An <ampersand> ’&’) appearing in the replacement shall be replaced by the string matching the BRE. The special meaning of ’&’ in this context can be suppressed by preceding it by a <backslash>. The characters "\n", where n is a digit, shall be replaced by the text matched by the corresponding back-reference expression. If the corresponding back-reference expression does not match, then the characters "\n" shall be replaced by the empty string. The special meaning of "\n" where n is a digit in this context, can be suppressed by preceding it by a <backslash>. For each other <backslash> encountered, the following character shall lose its special meaning (if any). The meaning of a <backslash> immediately followed by any character other than ’&’, <backslash>, a digit, or the delimiter character used for this command, is unspecified." Thus, 's,^,\/,', is non-portable. But 's,^,\\/,' should result in adding the two bytes \ and / at the front of the string. You are, however, correct that 'sed --posix' fails to do this. And considering Solaris behavior, I think we have a definite GNU sed bug. Paolo? $ echo hi | sed --posix 's,^,\/,' hi $ echo hi | sed --posix 's,^,\\/,' /hi $ echo hi | /usr/xpg4/bin/sed 's,^,\/,' /hi $ echo hi | /usr/xpg4/bin/sed 's,^,\\/,' \/hi Time for me to document this in the autoconf manual. -- Eric Blake