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