Home | History | Annotate | Line # | Download | only in unit-tests
varmod-assign-shell.mk revision 1.1
      1  1.1  rillig # $NetBSD: varmod-assign-shell.mk,v 1.1 2021/12/28 00:56:17 rillig Exp $
      2  1.1  rillig #
      3  1.1  rillig # Tests for the variable modifier '::!=', which assigns the output of a shell
      4  1.1  rillig # command to the variable, but only if the command exited successfully.  This
      5  1.1  rillig # is different from the variable assignment operator '!=', which also assigns
      6  1.1  rillig # when the shell command fails or crashes.
      7  1.1  rillig #
      8  1.1  rillig # The variable modifier '::!=' and its close relatives have been around since
      9  1.1  rillig # var.c 1.45 from 2000-06-01.
     10  1.1  rillig #
     11  1.1  rillig # Before 2020.08.25.21.16.53, the variable modifier '::!=' had a bug for
     12  1.1  rillig # unsuccessful commands, it put the previous value of the variable into the
     13  1.1  rillig # error message instead of the command that was executed.  That's where the
     14  1.1  rillig # counterintuitive error message 'make: "previous" returned non-zero status'
     15  1.1  rillig # comes from.
     16  1.1  rillig #
     17  1.1  rillig # BUGS
     18  1.1  rillig #	Even though the variable modifier '::!=' produces an error message,
     19  1.1  rillig #	the exit status of make is still 0.
     20  1.1  rillig #
     21  1.1  rillig #	Having an error message instead of a warning like for the variable
     22  1.1  rillig #	assignment operator '!=' is another unnecessary inconsistency.
     23  1.1  rillig 
     24  1.1  rillig DIRECT=         previous
     25  1.1  rillig DIRECT!=        echo output; false
     26  1.1  rillig 
     27  1.1  rillig ASSIGNED=       previous
     28  1.1  rillig _:=             ${ASSIGNED::!=echo output; false}
     29  1.1  rillig 
     30  1.1  rillig all:
     31  1.1  rillig 	@echo DIRECT=${DIRECT:Q}
     32  1.1  rillig 	@echo ASSIGNED=${ASSIGNED:Q}
     33