make-alpha
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Incompatibility with POSIX 2008--- /bin/sh -e?


From: David Boyce
Subject: Re: Incompatibility with POSIX 2008--- /bin/sh -e?
Date: Tue, 9 Jun 2009 23:12:09 -0400

I vote for the obvious .POSIX fix. Changing it unequivocally would
break a lot of makefiles, IMHO, and in mysterious ways, because
programming with -e is an acquired skill and not something most people
think about. Just for instance, an attempt at defensive programming
such as:

    test -f foo && rm -f foo

will backfire as the shell aborts before the &&. In fact all uses of
&& with -e are bad. Similarly, the common idiom

    some-command
    if [ $? -ne 0 ]; then
        (work around the problem)
    fi

will not work as designed. To work successfully with -e you have to
program "in the negative", e.g.

    test ! -f foo || rm -f foo

and most people just don't think like that. Also, if users were
required to keep compatible between GNU make and others, bugs like the
above would have been driven out, but many people prefer the
philosophy of just committing to use of GNU make on all platforms,
which means they'll never have been exposed to -e traps.

Of course I thought the main point was that POSIX itself isn't
supposed to change incompatibly. What is .POSIX supposed to mean now -
compatible with POSIX 2004 or 2008?[*]

[*] rhetorical question

On Tue, Jun 9, 2009 at 1:07 PM, Paul Smith<address@hidden> wrote:
> Hi all;
>
> I was just looking up something in the latest POSIX 2008 spec for make,
> and I noticed a very significant user-visible change between 2004 and
> 2008:
>
> In POSIX 2004, the description under "Makefile Execution" on how
> commands were to be executed says:
>
>        Command execution shall be as if the makefile command line were
>        the argument to the system() function.
>
> This is exactly how GNU make behaves.  However, in POSIX 2008 this
> sentence has been changed:
>
>        The execution line shall then be executed by a shell as if it
>        were passed as the argument to the system() interface, _except
>        that the shell -e option shall also be in effect_.
>
> (emphasis mine)  Ouch!  That is an enormous change.  GNU make does not
> use the -e flag and in fact I've closed many bugs requesting that it do
> so for compatibility with other versions of make as "not a bug", on the
> strength of the POSIX standard.
>
> It seems crazy to change this in GNU make: I imagine that it would cause
> problems for lots of makefiles out there that don't expect intermediate
> commands in a script to error.  Or, since many other make
> implementations DO set -e, maybe most makefiles would handle it and it
> won't hurt that much.
>
> Of course, alternatively we can set -e when the user adds the .POSIX
> special target.
>
> What are folks' opinions on this?  Bite the bullet and change it
> generally?  Leave it as is?  Change it only for .POSIX makefiles?
>
> --
> -------------------------------------------------------------------------------
>  Paul D. Smith <address@hidden>          Find some GNU make tips at:
>  http://www.gnu.org                      http://make.mad-scientist.us
>  "Please remain calm...I may be mad, but I am a professional." --Mad Scientist
>
>
> _______________________________________________
> Make-alpha mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/make-alpha
>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]