From owner-svn-src-head@freebsd.org Fri Jan 20 07:16:07 2017 Return-Path: Delivered-To: svn-src-head@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 D369ECB9A99; Fri, 20 Jan 2017 07:16:07 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail109.syd.optusnet.com.au (mail109.syd.optusnet.com.au [211.29.132.80]) by mx1.freebsd.org (Postfix) with ESMTP id 9BCB1191F; Fri, 20 Jan 2017 07:16:06 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from besplex.bde.org (c122-106-153-191.carlnfd1.nsw.optusnet.com.au [122.106.153.191]) by mail109.syd.optusnet.com.au (Postfix) with ESMTPS id A8102D6945B; Fri, 20 Jan 2017 18:15:59 +1100 (AEDT) Date: Fri, 20 Jan 2017 18:15:58 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Antoine Brodin cc: Xin LI , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r312404 - head/usr.bin/sed In-Reply-To: Message-ID: <20170120174258.X1938@besplex.bde.org> References: <201701190801.v0J81ZG9008267@repo.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.2 cv=BKLDlBYG c=1 sm=1 tr=0 a=Tj3pCpwHnMupdyZSltBt7Q==:117 a=Tj3pCpwHnMupdyZSltBt7Q==:17 a=kj9zAlcOel0A:10 a=6I5d2MoRAAAA:8 a=7glOachtraqBiMcJk8MA:9 a=CjuIK1q_8ugA:10 a=IjZwj45LgO3ly-622nXo:22 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Jan 2017 07:16:07 -0000 On Fri, 20 Jan 2017, Antoine Brodin wrote: > On Thu, Jan 19, 2017 at 9:01 AM, Xin LI wrote: >> Author: delphij >> Date: Thu Jan 19 08:01:35 2017 >> New Revision: 312404 >> URL: https://svnweb.freebsd.org/changeset/base/312404 >> >> Log: >> Use S_ISREG instead of manual & (also it's better to compare the >> result from & and the pattern instead of just assuming it's one bit >> value). >> >> Pointed out by Tianjie Mao . >> >> MFC after: 2 weeks >> Differential Revision: https://reviews.freebsd.org/D4827 > > Hi, > > sed -i no longer works on symlinks which breaks lots of ports. > Please revert and request an exp-run. sed() doesn't seem to actually understand symlinks (it has no flag like -h to prevent following them when opening files), so its use of lstat() to classify them is wrong. This was harmless for symlinks but not for other irregular file types pointed to by symlinks. The buggy S_IFREG test accidentally classified symlinks, sockets and whiteouts as regular, but failed classify the file type of the target of symlinks that will actually be used. The fixed test limits sed to "regular" files (including highly irregular ones in /proc). It is a bug for sed to have any restrictions on file types. This breaks device indepedence. Even /dev/std* was supposed to not work, but worked accidentally since these files happen to be implemented as symlinks. Their targets /dev/fd/[0-2] didn't work accidentally, but it was possible to trick sed into working on them by pointing to them using symlinks. Similarly for all file types. POSIX only requires sed to work on text files. I couldn't find anywhere where it clearly defines what a text file is or any restriction to regular files. It requires sed to work on stdin which is often a pipe, so it must not restrict on the file type found by fstat(). So a text file should defined as "a file of any type containing text". Utilities shouldn't be restricted to text either, but that is a larger bug. It is now difficult to even define text. Non-ASCII encodings of text look like binary to me. Bruce