Home | History | Annotate | Line # | Download | only in unit-tests
var-op-expand.mk revision 1.3
      1  1.3  rillig # $NetBSD: var-op-expand.mk,v 1.3 2020/11/08 13:46:15 rillig Exp $
      2  1.1  rillig #
      3  1.2  rillig # Tests for the := variable assignment operator, which expands its
      4  1.2  rillig # right-hand side.
      5  1.1  rillig 
      6  1.1  rillig # TODO: Implementation
      7  1.1  rillig 
      8  1.3  rillig # XXX: edge case: When a variable name refers to an undefined variable, the
      9  1.3  rillig # behavior differs between the '=' and the ':=' assignment operators.
     10  1.3  rillig # This bug exists since at least 1993-03-21.
     11  1.3  rillig #
     12  1.3  rillig # The '=' operator expands the undefined variable to an empty string, thus
     13  1.3  rillig # assigning to VAR_ASSIGN_.  In the name of variables to be set, it should
     14  1.3  rillig # really be forbidden to refer to undefined variables.
     15  1.3  rillig #
     16  1.3  rillig # The ':=' operator expands the variable name twice.  In one of these
     17  1.3  rillig # expansions, the undefined variable expression is preserved (controlled by
     18  1.3  rillig # preserveUndefined in VarAssign_EvalSubst), in the other expansion it expands
     19  1.3  rillig # to an empty string.  This way, 2 variables are created using a single
     20  1.3  rillig # variable assignment.  It's magic. :-/
     21  1.3  rillig .MAKEFLAGS: -dv
     22  1.3  rillig VAR_ASSIGN_${UNDEF}=	undef value
     23  1.3  rillig VAR_SUBST_${UNDEF}:=	undef value
     24  1.3  rillig .MAKEFLAGS: -d0
     25  1.3  rillig 
     26  1.1  rillig all:
     27  1.1  rillig 	@:;
     28