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