Paul Smith wrote, on 13 Dec 2021:
>
> Has anyone considered my comment on:
> 
> https://austingroupbugs.net/view.php?id=1505
> 
> ?  I'm unhappy with the resolution of this issue, to allow a conforming
> make to throw an error when expanding an unset variable.  No
> implementation I'm aware of does that or ever did that, and by allowing
> it we're suddenly changing tons of makefiles that would otherwise work
> properly to be indeterminate since it's allowed for a conforming
> implementation to throw such an error.
> 
> What's the point of allowing this?  Why shouldn't we just state that
> make implementations must expand unset variables to the empty string,
> which is what all implementations (that I'm aware of) do anyway?

The point is that any makefile that relies on an unset macro being
expanded to an empty string is not portable.  The only reason it ever
works is purely by luck.  When moving to a different implementation
of make (or even a newer version of the same implementation) it might
no longer work because the new make might have a non-empty default
value for that macro.  Also, when the makefile is used by a different
user it might not work because that user happens to have set an
environment variable of the same name (for an unrelated purpose).

Effectively, if a makefile expects an unset macro to expand to an
empty string, this is a bug waiting to be triggered.

In such situations it is generally agreed that it is better for the
problem to be brought to the attention of the author during development,
rather than for it to become a ticking time bomb.  This is, for example,
why it is considered best practice for shell script authors to put
"set -u" at the top of scripts, or for perl script authors to put
"use strict" there.  To facilitate something similar in make,
implementors may want to add an option to treat expansion of unset
macros as an error (and encourage its use during makefile development),
or, as with "use strict" in newer versions of perl, they may want to go
a step further and have that be the default, adding an option to turn it
off (for use with legacy makefiles that need that).  The standard should
allow both choices.

-- 
Geoff Clare <[email protected]>
The Open Group, Apex Plaza, Forbury Road, Reading, RG1 1AX, England

  • [Issue 8 dra... Austin Group Bug Tracker via austin-group-l at The Open Group
    • [Issue ... Austin Group Bug Tracker via austin-group-l at The Open Group
    • [Issue ... Austin Group Bug Tracker via austin-group-l at The Open Group
    • [Issue ... Austin Group Bug Tracker via austin-group-l at The Open Group
    • [Issue ... Austin Group Bug Tracker via austin-group-l at The Open Group
    • [Issue ... Austin Group Bug Tracker via austin-group-l at The Open Group
    • [Issue ... Austin Group Bug Tracker via austin-group-l at The Open Group
    • Re: [Is... Paul Smith via austin-group-l at The Open Group
      • Re:... Geoff Clare via austin-group-l at The Open Group
        • ... Chet Ramey via austin-group-l at The Open Group
          • ... Geoff Clare via austin-group-l at The Open Group
            • ... Chet Ramey via austin-group-l at The Open Group
          • ... Robert Elz via austin-group-l at The Open Group
        • ... Paul Smith via austin-group-l at The Open Group
          • ... Quentin Rameau via austin-group-l at The Open Group
            • ... Geoff Clare via austin-group-l at The Open Group
              • ... Paul Smith via austin-group-l at The Open Group

Reply via email to