NetBSD-Bugs archive

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

bin/51171: sed does not match newlines in regexps properly



>Number:         51171
>Category:       bin
>Synopsis:       sed does not match newlines in regexps properly
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri May 27 07:40:00 +0000 2016
>Originator:     Jarle Greipsland
>Release:        NetBSD 7.99.26
>Organization:
	
>Environment:
	
	
System: NetBSD singsaker.uninett.no 7.99.26 NetBSD 7.99.26 (SINGSAKER) #0: Sat Mar 26 12:52:06 CET 2016 jarle%singsaker.uninett.no@localhost:/usr/obj/sys/arch/i386/compile/SINGSAKER i386
Architecture: i386
Machine: i386
>Description:

The behavior of sed with regards to matching embedded newlines in the
pattern space seems to have changed from NetBSD 6 to NetBSD 7.

-------- script.sed ---------
1{h;d;}
2{H;d;}
3{H
  x
# Pattern space: line1 \n line2 \n \line3 (without spaces)
# Now, delete the first character of line1 and line2
  s/^[^\n]\([^\n]*\n\)[^\n]/\1/
}
-----------------------------

On NetBSD 6, the command
  (echo abc; echo def; echo ghi) | sed -f script.sed
will print:
bc
ef
ghi
which is what I would expect.

However, on NetBSD 7 and NetBSD-current, the command will print:
bc
def
hi
which is rather unexpected.

>How-To-Repeat:
See above.
	
>Fix:
	

>Unformatted:
 	
 	


Home | Main Index | Thread Index | Old Index