1# $NetBSD: varmod-assign-shell.mk,v 1.5 2023/06/01 20:56:35 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 27# expect+1: warning: "echo output; false" returned non-zero status 28DIRECT!= echo output; false 29 30ASSIGNED= previous 31.MAKEFLAGS: -dv # to see the actual command 32_:= ${ASSIGNED::!=echo output; ${:Ufalse}} 33.MAKEFLAGS: -d0 34 35all: 36 @echo DIRECT=${DIRECT:Q} 37 @echo ASSIGNED=${ASSIGNED:Q} 38