Home | History | Annotate | Line # | Download | only in unit-tests
varmod-shell.mk revision 1.6
      1  1.6  rillig # $NetBSD: varmod-shell.mk,v 1.6 2021/02/14 20:16:17 rillig Exp $
      2  1.1  rillig #
      3  1.6  rillig # Tests for the ':!cmd!' variable modifier, which runs the shell command
      4  1.6  rillig # given by the variable modifier and returns its output.
      5  1.3  rillig #
      6  1.4  rillig # This modifier has been added on 2000-04-29.
      7  1.4  rillig #
      8  1.4  rillig # See also:
      9  1.4  rillig #	ApplyModifier_ShellCommand
     10  1.1  rillig 
     11  1.4  rillig # The command to be run is enclosed between exclamation marks.
     12  1.4  rillig # The previous value of the expression is irrelevant for this modifier.
     13  1.4  rillig # The :!cmd! modifier turns an undefined expression into a defined one.
     14  1.4  rillig .if ${:!echo word!} != "word"
     15  1.4  rillig .  error
     16  1.4  rillig .endif
     17  1.4  rillig 
     18  1.4  rillig # If the command exits with non-zero, an error message is printed.
     19  1.4  rillig # XXX: Processing continues as usual though.
     20  1.4  rillig #
     21  1.5  rillig # Between 2000-04-29 and 2020-11-17, the error message mentioned the previous
     22  1.4  rillig # value of the expression (which is usually an empty string) instead of the
     23  1.4  rillig # command that was executed.  It's strange that such a simple bug could
     24  1.4  rillig # survive such a long time.
     25  1.4  rillig .if ${:!echo word; false!} != "word"
     26  1.4  rillig .  error
     27  1.4  rillig .endif
     28  1.4  rillig .if ${:Uprevious value:!echo word; false!} != "word"
     29  1.4  rillig .  error
     30  1.4  rillig .endif
     31  1.4  rillig 
     32  1.1  rillig all:
     33