Eric Blake wrote: > > This looks like a bug to me: \\ expands to nothing. No way to produce a > > backslash in the replacement. > > I concur.
Thanks. So I'm disabling --posix. Patch appended. > "... 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. Thanks for explaining. So the third of the mentioned sed expressions is not POSIX compliant. Fixing it, as attached. Bruno 2009-02-27 Bruno Haible <br...@clisp.org> * gnulib-tool (sed): Don't alias as "sed --posix". Reported by Eric Blake. *** gnulib-tool.orig 2009-02-28 03:14:43.000000000 +0100 --- gnulib-tool 2009-02-28 03:03:37.000000000 +0100 *************** *** 63,86 **** AUTOPOINT="${GETTEXTPATH}autopoint" fi ! # When using GNU sed, turn off as many GNU extensions as possible, ! # to minimize the risk of accidentally using non-portable features. ! # However, do this only for gnulib-tool itself, not for the code that ! # gnulib-tool generates, since we don't want "sed --posix" to leak ! # into makefiles. ! if (alias) > /dev/null 2>&1 && echo | sed --posix -e d >/dev/null 2>&1; then ! # Define sed as an alias. ! # It is not always possible to use aliases. Aliases are guaranteed to work ! # if the executing shell is bash and either it is invoked as /bin/sh or ! # is a version >= 2.0, supporting shopt. This is the common case. ! # Two other approaches (use of a variable $sed or of a function func_sed ! # instead of an alias) require massive, fragile code changes. ! # An other approach (use of function sed) requires `which sed` - but 'which' ! # is hard to emulate, due to missing "test -x" on some platforms. ! if test -n "$BASH_VERSION"; then ! shopt -s expand_aliases >/dev/null 2>&1 fi - alias sed='sed --posix' fi # sed_noop is a sed expression that does nothing. --- 63,90 ---- AUTOPOINT="${GETTEXTPATH}autopoint" fi ! # Disabled because "sed --posix" is buggy in GNU sed 4.1.5, see ! # <http://lists.gnu.org/archive/html/bug-gnulib/2009-02/msg00225.html>. ! if false; then ! # When using GNU sed, turn off as many GNU extensions as possible, ! # to minimize the risk of accidentally using non-portable features. ! # However, do this only for gnulib-tool itself, not for the code that ! # gnulib-tool generates, since we don't want "sed --posix" to leak ! # into makefiles. ! if (alias) > /dev/null 2>&1 && echo | sed --posix -e d >/dev/null 2>&1; then ! # Define sed as an alias. ! # It is not always possible to use aliases. Aliases are guaranteed to work ! # if the executing shell is bash and either it is invoked as /bin/sh or ! # is a version >= 2.0, supporting shopt. This is the common case. ! # Two other approaches (use of a variable $sed or of a function func_sed ! # instead of an alias) require massive, fragile code changes. ! # An other approach (use of function sed) requires `which sed` - but ! # 'which' is hard to emulate, due to missing "test -x" on some platforms. ! if test -n "$BASH_VERSION"; then ! shopt -s expand_aliases >/dev/null 2>&1 ! fi ! alias sed='sed --posix' fi fi # sed_noop is a sed expression that does nothing. 2009-02-27 Bruno Haible <br...@clisp.org> * gnulib-tool (func_import): Make the sed expression used to create the sed script for updating the .gitignore file POSIX compliant. Reported by Eric Blake. --- gnulib-tool.orig 2009-02-28 03:21:49.000000000 +0100 +++ gnulib-tool 2009-02-28 03:21:36.000000000 +0100 @@ -3571,7 +3571,7 @@ echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)" mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~ { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed - if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,\$/d,' < "$tmp"/ignore-removed; fi + if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi } > "$tmp"/sed-ignore-removed { cat "$destdir/$dir$ignore"~ sed -e "s|^|$anchor|" < "$tmp"/ignore-added