Home | History | Annotate | Line # | Download | only in unit-tests
      1  1.4  rillig # $NetBSD: varmod-exclam-shell.mk,v 1.4 2020/11/03 18:42:33 rillig Exp $
      2  1.1  rillig #
      3  1.4  rillig # Tests for the :!cmd! variable modifier, which evaluates the modifier
      4  1.4  rillig # argument, independent of the value or the name of the original variable.
      5  1.1  rillig 
      6  1.2  rillig .if ${:!echo hello | tr 'l' 'l'!} != "hello"
      7  1.4  rillig .  error
      8  1.2  rillig .endif
      9  1.2  rillig 
     10  1.2  rillig # The output is truncated at the first null byte.
     11  1.2  rillig # Cmd_Exec returns only a string pointer without length information.
     12  1.4  rillig # Truncating the output is not necessarily intended but may also be a side
     13  1.4  rillig # effect from the implementation.  Having null bytes in the output of a
     14  1.4  rillig # shell command is so unusual that it doesn't matter in practice.
     15  1.2  rillig .if ${:!echo hello | tr 'l' '\0'!} != "he"
     16  1.4  rillig .  error
     17  1.2  rillig .endif
     18  1.2  rillig 
     19  1.4  rillig # The newline at the end of the output is stripped.
     20  1.2  rillig .if ${:!echo!} != ""
     21  1.4  rillig .  error
     22  1.2  rillig .endif
     23  1.2  rillig 
     24  1.4  rillig # Only the final newline of the output is stripped.  All other newlines are
     25  1.4  rillig # converted to spaces.
     26  1.2  rillig .if ${:!echo;echo!} != " "
     27  1.4  rillig .  error
     28  1.2  rillig .endif
     29  1.2  rillig 
     30  1.4  rillig # Each newline in the output is converted to a space, except for the newline
     31  1.4  rillig # at the end of the output, which is stripped.
     32  1.2  rillig .if ${:!echo;echo;echo;echo!} != "   "
     33  1.4  rillig .  error
     34  1.2  rillig .endif
     35  1.1  rillig 
     36  1.1  rillig all:
     37  1.1  rillig 	@:;
     38