Bug 5246

Summary: sed global replace misses replacements
Product: Busybox Reporter: bugdal
Component: OtherAssignee: unassigned
Status: RESOLVED FIXED    
Severity: normal CC: busybox-cvs
Priority: P5    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Host: Target:
Build:

Description bugdal 2012-05-25 15:44:37 UTC
For example:

$ echo hello | busybox sed 's/l*/@/g'                                           
@he@o                                                                           
$ echo hello | sed 's/l*/@/g'                                                   
@h@e@o@                                                                         

The latter behavior (GNU sed) is the expected, conformant behavior.

It looks to me like sed has an off-by-one error advancing the position to search for the next match after making one replacement.
Comment 1 Denys Vlasenko 2012-06-04 12:56:25 UTC
Fixed in git:

commit 21f6fbf545e7fa58f0eaa444001a9d25bc37c4eb
Author: Denys Vlasenko <vda.linux@googlemail.com>
Date:   Mon Jun 4 14:44:47 2012 +0200

    sed: fix zero chars match/replace