Subject: bin/24641: possible bug in sed(1)
To: None <gnats-bugs@gnats.netbsd.org>
From: None <wiz@NetBSD.org>
List: netbsd-bugs
Date: 03/02/2004 15:24:47
>Number:         24641
>Category:       bin
>Synopsis:       possible bug in sed(1)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Mar 02 14:26:00 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator:     Thomas Klausner
>Release:        NetBSD 1.6ZF
>Organization:
	
>Environment:
	
	
>Description:
The following script works with GNU sed 4.07, but not with sed in -current (1.6ZF).

echo "a{b,c{x,y}}" | sed '
:a
s%{\([^,]*\)}%\1%g
s%{\(\([^{},]*,\)*\)\([^{},]*\){\([^,{}]*\),\?\([^{}]*\)}\([^{}]*\)}%{\1\3\4,\3{\5}\6}%
t a
:b
s%{\([^,]*\)}%\1%g
s%\([^{ ]*\){\([^,{}]*\),\?\([^{}]*\)}\([^ ]*\)%\1\2\4 \1{\3}\4%
t b'

GNU sed outputs "ab acx acy" while NetBSD sed outputs "a{b,c{x,y}}".

I don't know sed enough to know if the expression conforms to some standard or not.
It should probably be fixed anyway for compatibility reasons; e.g. pkgsrc/net/jigdo
uses something like this.
>How-To-Repeat:
Paste code above in shell window.
>Fix:
Not provided.
>Release-Note:
>Audit-Trail:
>Unformatted: