From owner-freebsd-standards@FreeBSD.ORG Fri May 7 10:00:40 2004 Return-Path: Delivered-To: freebsd-standards@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CF9E816A4CE for ; Fri, 7 May 2004 10:00:40 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0401F43D1F for ; Fri, 7 May 2004 10:00:40 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) i47H0dck029429 for ; Fri, 7 May 2004 10:00:39 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.11/8.12.11/Submit) id i47H0diV029426; Fri, 7 May 2004 10:00:39 -0700 (PDT) (envelope-from gnats) Resent-Date: Fri, 7 May 2004 10:00:39 -0700 (PDT) Resent-Message-Id: <200405071700.i47H0diV029426@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-standards@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, "Mark D. Baushke" Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 195C916A4CE for ; Fri, 7 May 2004 09:56:09 -0700 (PDT) Received: from colo-dns-ext1.juniper.net (colo-dns-ext1.juniper.net [207.17.137.57]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3A89043D53 for ; Fri, 7 May 2004 09:56:08 -0700 (PDT) (envelope-from mdb@juniper.net) Received: from merlot.juniper.net (merlot.juniper.net [172.17.27.10]) i47Gu2l25289; Fri, 7 May 2004 09:56:02 -0700 (PDT) (envelope-from mdb@juniper.net) Received: from juniper.net (garnet.juniper.net [172.17.28.17]) by merlot.juniper.net (8.11.3/8.11.3) with ESMTP id i47GtvJ42909; Fri, 7 May 2004 09:55:57 -0700 (PDT) (envelope-from mdb@juniper.net) Message-Id: <11525.1083948957@juniper.net> Date: Fri, 07 May 2004 09:55:57 -0700 From: "Mark D. Baushke" Sender: mdb@juniper.net To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 cc: Paul Eggert cc: "Simon J. Gerraty" Subject: standards/66357: make POSIX conformance problem ('sh -e' & '+' command-line flag) X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 May 2004 17:00:40 -0000 >Number: 66357 >Category: standards >Synopsis: make POSIX conformance problem ('sh -e' & '+' command-line) >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-standards >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri May 07 10:00:38 PDT 2004 >Closed-Date: >Last-Modified: >Originator: Mark Baushke >Release: FreeBSD 5.2-RELEASE i386 >Organization: Juniper Networks, Inc. >Environment: System: FreeBSD rat52.juniper.net 5.2-RELEASE FreeBSD 5.2-RELEASE #0: Sun Jan 11 04:21:45 GMT 2004 root@wv1u.btc.adaptec.com:/usr/obj/usr/src/sys/GENERIC i386 >Description: Background: POSIX 1003.2-1997 states that each makefile command line is processed as if given to system(3) (see URL http://www.opengroup.org/onlinepubs/009695399/utilities/make.html) POSIX 1003.1-2004 (as well as older versions of the standard) states that system() does not use the "sh -e" command to exit immediately if any untested command fails in non-interactive mode. (see URL http://www.opengroup.org/onlinepubs/009695399/functions/system.html) The FreeBSD /usr/bin/make program generates an error and does not support the '+' command line flag properly. (tested on FreeBSD 2.2.8-RELEASE, 3.3-RELEASE, 4.2-RELEASE, 4.10-PRERELEASE and 5.2-RELEASE versions) My guess is that the .POSIX: directive in the test case would not have much impact as the sys.mk file seems to be read before the first Makefile is opened, but I have added that rule to underline that this change is really only required in order to be POSIX compliant. Should you wish to retain your existing behavior, that would be fine as long as the behavior is modified as expected when the .POSIX: directive is given. I have consulted with Simon J. Gerraty who commits changes to the NetBSD version of make as well as providing portable versions of bmake for other platforms (see URL http://www.crufty.net/help/sjg/bmake.html). He says he has committed a patch to the NetBSD -current version of the make program. Part of the e-mail exchange focused on this problem is found here: http://mail-index.netbsd.org/tech-toolchain/2004/05/05/0008.html After my .signature are the log message and URLs for the changes made to the NetBSD. >How-To-Repeat: How to reproduce the problem: The following Makefile --------------- start Makefile --------------- .POSIX: all: x plus sub err x: @echo "Hello,"; false; echo "World" plus: @echo a command +@echo "a command prefixed by '+' executes even with -n" @echo another command subs: @echo make -n @${.MAKE} -f ${MAKEFILE} -n plus @echo make -n -j1 @${.MAKE} -f ${MAKEFILE} -n -j1 plus err: @(echo Now we expect an error...; exit 1) @echo "Oops! you shouldn't see this!" --------------- end Makefile --------------- The make x command should therefore generate two lines: Hello, World with no error on a 'make' command that is POSIX-compliant. The make -n plus command should print echo a command echo "a command prefixed by '+' executes even with -n" a command prefixed by '+' executes even with -n echo another command to show that it is not executing the first and last echo command, but is executing the middle one. The make err command should print Now we expect an error... and exit with an error code 1. Running all of the tests may require adding a few command-line arguments if the paricular version of make does not support setting the .MAKE or MAKEFILE macros such as this: make .MAKE=/usr/bin/make MAKEFILE=Makefile However, as those macros are not required by the POSIX standard, you don't need to worry if they are not being set by default. --------------- begin test results for FreeBSD 5.2-RELEASE --------------- % /usr/bin/make Hello, *** Error code 1 Stop in /tmp/mdb.foo. % /usr/bin/make plus % /usr/bin/make plus a command +@echo "a command prefixed by '+' executes even with -n" +@echo:No such file or directory *** Error code 1 Stop in /tmp/mdb.foo. % /usr/bin/make -n plus echo a command +@echo "a command prefixed by '+' executes even with -n" echo another command % /usr/bin/make -n .MAKE=/usr/bin/make subs echo make -n /usr/bin/make -f Makefile -n plus echo make -n -j1 /usr/bin/make -f Makefile -n -j1 plus % /usr/bin/make .MAKE=/usr/bin/make -n subs echo make -n /usr/bin/make -f Makefile -n plus echo make -n -j1 /usr/bin/make -f Makefile -n -j1 plus % /usr/bin/make err Now we expect an error... *** Error code 1 Stop in /tmp/mdb.foo. % /usr/bin/make -n err (echo Now we expect an error...; exit 1) echo "Oops! you shouldn't see this!" % pwd /tmp/mdb.foo % --------------- end test reults for FreeBSD 5.2-RELEASE --------------- >Fix: Committed to the NetBSD cvs repository on Fri May 7 08:12:15 2004 UTC by sjg Log message: Remove use of sh -e when running in compat mode. Its not posix compliant and serves very little purpose. With this change compat and jobs modes are consistent wrt how they treat each line of a script. Add support for the '+' command line prefix as required by posix. Lines prefixed with '+' are executed even when -n is given. [Actually posix says they should also be done for -q and -t] PR: Reviewed by: jmc http://cvsweb.netbsd.org/bsdweb.cgi/src/usr.bin/make/compat.c.diff?r1=1.53&r2=1.54 http://cvsweb.netbsd.org/bsdweb.cgi/src/usr.bin/make/nonints.h.diff?r1=1.31&r2=1.32 http://cvsweb.netbsd.org/bsdweb.cgi/src/usr.bin/make/job.c.diff?r1=1.84&r2=1.85 http://cvsweb.netbsd.org/bsdweb.cgi/src/usr.bin/make/unit-tests/Makefile.diff?r1=1.12&r2=1.13 http://cvsweb.netbsd.org/bsdweb.cgi/src/usr.bin/make/unit-tests/test.exp.diff?r1=1.11&r2=1.12 http://cvsweb.netbsd.org/bsdweb.cgi/src/usr.bin/make/unit-tests/posix >Release-Note: >Audit-Trail: >Unformatted: