From owner-freebsd-arch@FreeBSD.ORG Tue May 24 00:21:08 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 DE01716A41C; Tue, 24 May 2005 00:21:07 +0000 (GMT) (envelope-from okumoto@ucsd.edu) Received: from oec-server4.ucsd.edu (oec-server4.ucsd.edu [132.239.8.84]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9707D43D1F; Tue, 24 May 2005 00:21:07 +0000 (GMT) (envelope-from okumoto@ucsd.edu) Received: from oec-server2.ucsd.edu (oec-server2.ucsd.edu [132.239.8.82]) by oec-server4.ucsd.edu (8.12.10/8.12.10) with ESMTP id j4O0L6uv046442; Mon, 23 May 2005 17:21:06 -0700 (PDT) (envelope-from okumoto@ucsd.edu) Received: (from okumoto@localhost) by oec-server2.ucsd.edu (8.12.9p2/8.12.9/Submit) id j4O0L665032530; Mon, 23 May 2005 17:21:06 -0700 (PDT) (envelope-from okumoto@ucsd.edu) X-Authentication-Warning: oec-server2.ucsd.edu: okumoto set sender to okumoto@ucsd.edu using -f To: Harti Brandt References: <20050523153118.C28521@beagle.kn.op.dlr.de> From: Max Okumoto In-Reply-To: <20050523153118.C28521@beagle.kn.op.dlr.de> (Harti Brandt's message of "Mon, 23 May 2005 15:51:16 +0200 (CEST)") User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (berkeley-unix) Date: Mon, 23 May 2005 17:21:06 -0700 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Milter: oec-server4.ucsd.edu spamtagger ($Revision: 1.100 $) X-Milter: oec-server4.ucsd.edu mailscan ($Revision: 1.143 $) X-MailscanStatus: Pass X-Spam-Level: Level X-Spam-Checker-Version: SpamAssassin 2.60 (1.212-2003-09-23-exp) on oec-server4.ucsd.edu X-Spam-Status: No, hits=-104.9 required=5.0 tests=BAYES_00, USER_IN_WHITELIST autolearn=ham version=2.60 Cc: arch@freebsd.org Subject: Re: Handling of shell builtins in make(1) X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 May 2005 00:21:08 -0000 Harti Brandt writes: > 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. 4. Extend .SHELL: to allow specifing a list of built-in. And then we should define them in bsd.sys.mk or some other config file. > 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? This will allow people to add keywords for their shells, and remove that stuff from the make source code. Hard coding it in the binary is wrong. Max Okumoto > > harti > _______________________________________________ > freebsd-arch@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-arch > To unsubscribe, send any mail to "freebsd-arch-unsubscribe@freebsd.org"