From owner-freebsd-arch@FreeBSD.ORG Mon May 23 13:51:17 2005 Return-Path: X-Original-To: arch@freebsd.org Delivered-To: freebsd-arch@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7C46416A422 for ; Mon, 23 May 2005 13:51:17 +0000 (GMT) (envelope-from Hartmut.Brandt@dlr.de) Received: from smtp-1.dlr.de (smtp-1.dlr.de [195.37.61.185]) by mx1.FreeBSD.org (Postfix) with ESMTP id 090F343D49 for ; Mon, 23 May 2005 13:51:16 +0000 (GMT) (envelope-from Hartmut.Brandt@dlr.de) Received: from beagle.kn.op.dlr.de ([129.247.173.6]) by smtp-1.dlr.de over TLS secured channel with Microsoft SMTPSVC(6.0.3790.211); Mon, 23 May 2005 15:51:15 +0200 Date: Mon, 23 May 2005 15:51:16 +0200 (CEST) From: Harti Brandt X-X-Sender: brandt_h@beagle.kn.op.dlr.de To: arch@freebsd.org Message-ID: <20050523153118.C28521@beagle.kn.op.dlr.de> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-OriginalArrivalTime: 23 May 2005 13:51:15.0948 (UTC) FILETIME=[7D2CB2C0:01C55F9E] Cc: Subject: Handling of shell builtins in make(1) X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Harti Brandt List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 May 2005 13:51:17 -0000 Hi all, I think I found a problem in the shell code in make(1), but I'm not sure whether to fix it or not and how. The problem is as follows: in compat mode (this is the default mode when make(1) is not called with -j) the command lines of a target are executed by one shell per line (this is also how Posix wants it). To reduce the number of shells make does an optimisation: when the command line does not contain one of a pre-defined set of meta characters and does not start with one of a predefined set of shell builtins, make directly exec's the command instead of using an intermediate shell. The problem is that the current list of builtins is limited to: alias cd eval exec exit read set ulimit unalias umask unset wait Obviously this is not the full set of shell builtins and does also not contain the shell reserved words. The result of this is that for one and the same command you can get different behaviour whether you execute it via make(1) or via sh -c '...'. As an example take echo(1). When called via the sh -c you get the builtin echo which supports the -e option, when executed by make(1) you get /bin/echo which doesn't. If you suddenly include a shell meta character in the command line: foo: echo "MAKEFLAGS: ${MAKEFLAGS}" you suddenly get also the builtin (':' is a meta character). For the reserved words the situation is almost the same. With the following makefile: foo: if one gets: if:No such file or directory, while foo: if [ -x /bin/sh ] ; then echo hey ; fi you get what you expect. I think all this may be very confusing. The question is what to do. I see the following options: 1. leave it as it is. 2. include the Posix reserved words and builtins into the list. 3. include all reserved words and builtins of our shell into the list. Option (3) is probably best. With (2) you still get different behaviour for the two command lines in: foo: bind -h bind -h * (the first line will try to find bind in the path while the second will execute the shell builtin). Opinions? harti