Home | History | Annotate | Line # | Download | only in unit-tests
varmod.mk revision 1.3
      1 # $NetBSD: varmod.mk,v 1.3 2020/09/13 07:42:20 rillig Exp $
      2 #
      3 # Tests for variable modifiers, such as :Q, :S,from,to or :Ufallback.
      4 
      5 DOLLAR1=	$$
      6 DOLLAR2=	${:U\$}
      7 
      8 # To get a single '$' sign in the value of a variable expression, it has to
      9 # be written as '$$' in a literal variable value.
     10 #
     11 # See Var_Parse, where it calls Var_Subst.
     12 .if ${DOLLAR1} != "\$"
     13 .  error
     14 .endif
     15 
     16 # Another way to get a single '$' sign is to use the :U modifier.  In the
     17 # argument of that modifier, a '$' is escaped using the backslash instead.
     18 #
     19 # See Var_Parse, where it calls Var_Subst.
     20 .if ${DOLLAR2} != "\$"
     21 .  error
     22 .endif
     23 
     24 # It is also possible to use the :U modifier directly in the expression.
     25 #
     26 # See Var_Parse, where it calls Var_Subst.
     27 .if ${:U\$} != "\$"
     28 .  error
     29 .endif
     30 
     31 # XXX: As of 2020-09-13, it is not possible to use '$$' in a variable name
     32 # to mean a single '$'.  This contradicts the manual page, which says that
     33 # '$' can be escaped as '$$'.
     34 .if ${$$:L} != ""
     35 .  error
     36 .endif
     37 
     38 # In lint mode, make prints helpful error messages.
     39 # For compatibility, make does not print these error messages in normal mode.
     40 # Should it?
     41 .MAKEFLAGS: -dL
     42 .if ${$$:L} != ""
     43 .  error
     44 .endif
     45 
     46 # A '$' followed by nothing is an error as well.
     47 .if ${:Uword:@word@${word}$@} != "word"
     48 .  error
     49 .endif
     50 
     51 all: # nothing
     52