standards/66357: make POSIX conformance problem ('sh -e' & '+'
command-line flag)
Harti Brandt
novo at cs.tu-berlin.de
Sat May 8 06:50:31 PDT 2004
The following reply was made to PR standards/66357; it has been noted by GNATS.
From: Harti Brandt <novo at cs.tu-berlin.de>
To: "Mark D. Baushke" <mdb at juniper.net>
Cc: FreeBSD-gnats-submit at FreeBSD.ORG,
Paul Eggert <eggert at cs.ucla.edu>,
"Simon J. Gerraty" <sjg at crufty.net>, freebsd-standards at FreeBSD.ORG
Subject: Re: standards/66357: make POSIX conformance problem ('sh -e' & '+'
command-line flag)
Date: Sat, 8 May 2004 15:43:45 +0200 (CEST)
On Fri, 7 May 2004, Mark D. Baushke wrote:
>
> >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 at 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
> + at 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
> + at echo "a command prefixed by '+' executes even with -n"
> + at echo:No such file or directory
> *** Error code 1
>
> Stop in /tmp/mdb.foo.
> % /usr/bin/make -n plus
> echo a command
> + at 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:
> _______________________________________________
> freebsd-standards at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-standards
> To unsubscribe, send any mail to "freebsd-standards-unsubscribe at freebsd.org"
>
>
The 'sh -e' servers a purpose if you have a more complicated shell line
say a loop. Without -e make will not stop even if there is an error in
an inner command of a shell loop, while with -e it will exit. I'd say
that not using -e is a posix-bug, not a feature and, in fact, there has
been thoughts on the austin group mailing list to review this.
I'd think even if we remove the -e in the posix case, we must retain it
in the non-posix case.
harti
More information about the freebsd-standards
mailing list