Date: Mon, 04 Dec 2017 05:41:38 +0000 From: bugzilla-noreply@freebsd.org To: freebsd-bugs@FreeBSD.org Subject: [Bug 172862] sed(1) improperly deals with escape chars Message-ID: <bug-172862-8-hpVrMWzSiY@https.bugs.freebsd.org/bugzilla/> In-Reply-To: <bug-172862-8@https.bugs.freebsd.org/bugzilla/> References: <bug-172862-8@https.bugs.freebsd.org/bugzilla/>
next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D172862 Yuri Pankov <yuripv@gmx.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |yuripv@gmx.com --- Comment #3 from Yuri Pankov <yuripv@gmx.com> --- Despite what comment #1 says, sed does NOT match literal "\t" to a tab character outside [] as well -- quoting http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html: 9.3.2 BRE Ordinary Characters The interpretation of an ordinary character preceded by an unescaped <backslash> ('\\') is undefined. 9.4.2 ERE Ordinary Characters The interpretation of an ordinary character preceded by an unescaped <backslash> ( '\\' ) is undefined. There's an exception that is important here that <backslash> loses it's spe= cial meaning inside the bracket expression, so in your examples the bracket expression "[\t ]" correctly matches the 't' character and whitespace. Given the above, GNU sed actually violates the standard which defines the '= s' command as the following: [2addr]s/BRE/replacement/flags ...so all BRE (ERE with -E) rules apply here. I would agree that *outside* of the bracket expression we could make "\t" m= atch the tab character (that's what libtre does apparently) as it's more readable than inserting literal tab characters in RE, but inside the bracket express= ion GNU sed is clearly wrong, and our sed (through regex(3)) is doing the right thing. (I just hope I'm understanding everything correctly here, of course) --=20 You are receiving this mail because: You are the assignee for the bug.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-172862-8-hpVrMWzSiY>