Subject: bug#23493: gnu sed word replace bug

From: Davide Brini <[email-masked]>
Date: Mon, 9 May 2016 23:17:04 +0200

On Tue, 10 May 2016 01:02:35 +0800, xingzx <[email-masked]> wrote:

> Hello:
> 	I’m not sure whether it’s gnu sed’s bug, but it just behaves
> different with Mac OS X :
> 
> gnu sed(/usr/local/bin/sed (GNU sed) 4.2.2):
> ~ $ echo '<WebCore/DOMElement.h>'| /usr/local/bin/sed -E
> 's/\<WebCore\//\<WebKitLegacy\//' <<WebKitLegacy/DOMElement.h>
> 
> Mac 10.11.3 sed(/usr/bin/sed):
> ~ $ echo '<WebCore/DOMElement.h>'| /usr/bin/sed -E
> 's/\<WebCore\//\<WebKitLegacy\//' <WebKitLegacy/DOMElement.h>

No bug, in GNU sed, \< and \> are special and get interpreted, while on
OSX sed the \ in the \< combination is silently stripped. 
So if you just want to match a literal lesser sign, just use it unescaped
(and in any case, you surely don't have to escape it in the replacement
part):

$ echo '<WebCore/DOMElement.h>'| sed -E 's/<WebCore\//<WebKitLegacy\//'
<WebKitLegacy/DOMElement.h>

-- 
D.