From owner-svn-src-all@FreeBSD.ORG Fri Nov 19 16:24:31 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0F9871065674; Fri, 19 Nov 2010 16:24:31 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from mx1.stack.nl (relay02.stack.nl [IPv6:2001:610:1108:5010::104]) by mx1.freebsd.org (Postfix) with ESMTP id A1CBD8FC1D; Fri, 19 Nov 2010 16:24:30 +0000 (UTC) Received: from turtle.stack.nl (turtle.stack.nl [IPv6:2001:610:1108:5010::132]) by mx1.stack.nl (Postfix) with ESMTP id 12B6F35A86E; Fri, 19 Nov 2010 17:24:30 +0100 (CET) Received: by turtle.stack.nl (Postfix, from userid 1677) id 05A5317042; Fri, 19 Nov 2010 17:24:29 +0100 (CET) Date: Fri, 19 Nov 2010 17:24:29 +0100 From: Jilles Tjoelker To: Alexey Dokuchaev Message-ID: <20101119162429.GD7614@stack.nl> References: <201011191256.oAJCuDFH074482@svn.freebsd.org> <20101119152127.GA29131@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20101119152127.GA29131@FreeBSD.org> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r215520 - in head: bin/sh share/man/man1 usr.bin/printf X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Nov 2010 16:24:31 -0000 On Fri, Nov 19, 2010 at 03:21:27PM +0000, Alexey Dokuchaev wrote: > On Fri, Nov 19, 2010 at 12:56:13PM +0000, Jilles Tjoelker wrote: > > Side effect: printf is now always the builtin version (which behaves > > identically to /usr/bin/printf) and cannot be overridden via PATH (except > > via the undocumented %builtin mechanism). > Are there any plans to document it? It would have to be fixed first so it has sensible behaviour. Right now all builtins, including ones that must execute as a builtin for full functionality, can be overridden via %builtin, which does not seem to make a lot of sense. POSIX (XCU 2.9.1.1 Command Search and Execution) requires that special builtins and some other builtins such as bg, cd and command be found without a PATH search. For consistency with execvp(3) and perhaps also for POSIX compliance, the special cases with % are not really good. Another way to allow overriding builtins would be to make each overridable builtin pretend to be in a directory (e.g. /usr/bin) and be found at that point in the PATH search. For example, printf could pretend to be /usr/bin/printf, which would mean PATH=/usr/bin printf would find the builtin, but PATH=/elsewhere:/usr/bin printf would find /elsewhere/printf if it exists. Command names containing slashes would not participate in this and always invoke the external program. For example, /usr/bin/printf would continue to use the external program. Some builtins in ksh93 (but not printf) work this way. If the echo builtin pretends to be /bin/echo, it is a bit strange because the two utilities are rather incompatible. If I take POSIX's list and add other utilities that must execute as a builtin for full functionality, only very few utilities remain. Many of these are non-standard and are not present in the filesystem. In the specific case of printf, note that the bash, ksh93 and zsh versions of the printf builtin support %n, writing the result into a specified shell variable, which can only work if it is a builtin. Although our printf does not support this and I do not plan on adding it, it means that various shell authors think printf should always be a builtin. The general issue is that I do not know how exactly %builtin is or can be used in practice. -- Jilles Tjoelker