Subject: bin/28126: sed fails to match empty back-reference
To: None <gnats-bugs@gnats.netbsd.org>
From: Andrew Brown <atatat@atatdot.net>
List: netbsd-bugs
Date: 11/08/2004 21:36:10
>Number:         28126
>Category:       bin
>Synopsis:       sed fails to match empty back-reference
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Nov 09 02:37:00 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator:     TheMan
>Release:        2.99.10
>Organization:
none
>Environment:
	
System: NetBSD this 2.99.10 NetBSD 2.99.10 (THAT) #346: Mon Nov  8 07:58:51 EST 2004  andrew@this:/usr/src/sys/arch/i386/compile/THAT i386


>Description:

	sed fails to match an empty back-reference.  i discovered this
after i partially zorched my cvs tree and my Root and Repository files
mostly ended up containing garbage.  finding improper Repository files
should have been as simple as:

	% cd /usr/src
	% find ./bin -path \*/CVS/Repository | \
		xargs grep -H . | \
		sed -n '/^\.\(.*\)\/CVS\/Repository:src\1$/d;p'

yet the first line out is 

	./CVS/Repository:src

which is clearly fine.

>How-To-Repeat:

on netbsd current

	% echo foobar | sed -ne '/foo\(.*\)bar\1/p'
	% echo foo1bar1 | sed -ne '/foo\(.*\)bar\1/p'
	foo1bar1

compared to solaris:

	% echo foobar | sed -ne '/foo\(.*\)bar\1/p'
	foobar

linux:

	% echo foobar | sed -ne '/foo\(.*\)bar\1/p'
	foobar

netbsd 2.0_RC4:

	% echo foobar | sed -ne '/foo\(.*\)bar\1/p'
	foobar

netbsd 1.6ZL:

	% echo foobar | sed -ne '/foo\(.*\)bar\1/p'
	foobar

etc.

>Fix:

not sure.  repeatedly updating my sed tree to something older (and
older and older) didn't yield any good results, so i suppose it might
be a recent change to regex stuff in libc?
>Release-Note:
>Audit-Trail:
>Unformatted: