From owner-freebsd-bugs@freebsd.org Mon Dec 4 05:41:38 2017 Return-Path: Delivered-To: freebsd-bugs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5DFB5DEEA22 for ; Mon, 4 Dec 2017 05:41:38 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4C8BD7974A for ; Mon, 4 Dec 2017 05:41:38 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from bugs.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id vB45fcww076121 for ; Mon, 4 Dec 2017 05:41:38 GMT (envelope-from bugzilla-noreply@freebsd.org) From: bugzilla-noreply@freebsd.org To: freebsd-bugs@FreeBSD.org Subject: [Bug 172862] sed(1) improperly deals with escape chars Date: Mon, 04 Dec 2017 05:41:38 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: bin X-Bugzilla-Version: 9.1-STABLE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: yuripv@gmx.com X-Bugzilla-Status: In Progress X-Bugzilla-Resolution: X-Bugzilla-Priority: Normal X-Bugzilla-Assigned-To: freebsd-bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Dec 2017 05:41:38 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D172862 Yuri Pankov changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |yuripv@gmx.com --- Comment #3 from Yuri Pankov --- 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 ('\\') is undefined. 9.4.2 ERE Ordinary Characters The interpretation of an ordinary character preceded by an unescaped ( '\\' ) is undefined. There's an exception that is important here that 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.=