bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gnulib-tool bug


From: Bruno Haible
Subject: Re: gnulib-tool bug
Date: Sat, 28 Feb 2009 00:31:34 +0100
User-agent: KMail/1.9.9

Eric Blake wrote:
> > > /^test-freadptr.c/d
> > 
> > ok so far.

Actually, that was not ok: it should be
      /^test-freadptr.c$/d

> > > /^/test-freadptr.c/d
> > 
> > This should be  /^\/test-freadptr.c/d

Actually this should be
     /^\/test-freadptr.c$/d

> > For me, with bash and sed-4.1.5, the result of both is
> > /^\/test-freadseek.sh$/d
> > 
> > And on your side?
> 
> Using bash 3.2 and set 4.1.5, and both commands gave
> 
> /^\/test-freadseek.sh$/d

Ah! The culprit is the --posix option that gnulib-tool adds:

$ doubly_escaped_anchor='\\/'
$ echo 'test-freadseek.sh' | \
  sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,\$/d,'
/^\/test-freadseek.sh$/d
$ echo 'test-freadseek.sh' | \
  sed --posix -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,\$/d,'
/^/test-freadseek.sh/d

It ate not only the backslash but also the dollar sign. In fact, it affects
all three substitutions:

1) $ echo a/b | sed -e 's,/,\\/,g'
   a\/b
   $ echo a/b | sed --posix -e 's,/,\\/,g'
   a/b
   $ echo a/b | sed --posix -e 's,/,\\\/,g'
   ab
   $ echo a/b | sed --posix -e 's,/,\\\\/,g'
   a/b
   $ echo a/b | sed --posix -e 's,/,\\\\\/,g'
   ab
   $ echo a/b | sed --posix -e 's,/,\\\\\\/,g'
   a/b

This looks like a bug to me: \\ expands to nothing. No way to produce a
backslash in the replacement.

2) $ echo foo | sed -e 's,^,/^\\/,'
   /^\/foo
   $ echo foo | sed --posix -e 's,^,/^\\/,'
   /^/foo
   $ echo foo | sed --posix -e 's,^,/^\\\/,'
   /^foo
   $ echo foo | sed --posix -e 's,^,/^\\\\/,'
   /^/foo

This looks like a bug as well.

3) $ echo foo | sed -e 's,$,\$/d,'
   foo$/d
   $ echo foo | sed --posix -e 's,$,\$/d,'
   foo/d
   $ echo foo | sed --posix -e 's,$,$/d,'
   foo$/d

And this?

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.

Bruno




reply via email to

[Prev in Thread] Current Thread [Next in Thread]