GNU bug report logs - #23493
gnu sed word replace bug

Previous Next

Package: sed;

Reported by: xingzx <richshaw <at> 126.com>

Date: Mon, 9 May 2016 17:19:03 UTC

Severity: normal

Tags: notabug

Done: Assaf Gordon <assafgordon <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Davide Brini <dave_br <at> gmx.com>
To: bug-sed <at> gnu.org
Subject: Re: bug#23493: gnu sed word replace bug
Date: Mon, 9 May 2016 23:17:04 +0200
On Tue, 10 May 2016 01:02:35 +0800, xingzx <richshaw <at> 126.com> 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.




This bug report was last modified 8 years and 173 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.