make(1): move test for the ::= modifier to varmod-assign
This commit is contained in:
parent
056172a33c
commit
b8d9af4f48
|
@ -123,13 +123,6 @@ make: Unfinished modifier for FIB ('}' missing)
|
|||
make: Unfinished modifier for FIB ('}' missing)
|
||||
|
||||
then
|
||||
mod-assign-parse:
|
||||
make: Unknown modifier ':'
|
||||
|
||||
make: Bad modifier `:' for
|
||||
value}
|
||||
make: Unfinished modifier for ASSIGN ('}' missing)
|
||||
|
||||
mod-remember-parse:
|
||||
1 1 2 3 5 8 13 21 34
|
||||
make: Unknown modifier '_'
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $Id: moderrs.mk,v 1.14 2020/08/09 15:15:29 rillig Exp $
|
||||
# $Id: moderrs.mk,v 1.15 2020/08/25 20:49:40 rillig Exp $
|
||||
#
|
||||
# various modifier error tests
|
||||
|
||||
|
@ -20,7 +20,6 @@ all: mod-regex-undefined-subexpression
|
|||
all: mod-ts-parse
|
||||
all: mod-t-parse
|
||||
all: mod-ifelse-parse
|
||||
all: mod-assign-parse
|
||||
all: mod-remember-parse
|
||||
all: mod-sysv-parse
|
||||
|
||||
|
@ -164,12 +163,6 @@ mod-ifelse-parse:
|
|||
@echo ${FIB:?then:else
|
||||
@echo ${FIB:?then:else}
|
||||
|
||||
mod-assign-parse:
|
||||
@echo $@:
|
||||
@echo ${ASSIGN::x} # 'x' is an unknown assignment operator
|
||||
@echo ${::=value} # trying to set the empty variable
|
||||
@echo ${ASSIGN::=value # missing closing brace
|
||||
|
||||
mod-remember-parse:
|
||||
@echo $@:
|
||||
@echo ${FIB:_} # ok
|
||||
|
|
|
@ -10,4 +10,14 @@ mod-assign-nested: then1t1
|
|||
mod-assign-nested: else2e2
|
||||
mod-assign-nested: then3t3
|
||||
mod-assign-nested: else4e4
|
||||
make: Bad modifier `:' for
|
||||
value}
|
||||
make: Bad modifier `:' for
|
||||
mod-assign-empty: overwritten}
|
||||
mod-assign-empty: VAR=overwritten
|
||||
make: Unknown modifier ':'
|
||||
|
||||
sysv:y
|
||||
make: Unfinished modifier for ASSIGN ('}' missing)
|
||||
|
||||
exit status 0
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
# $NetBSD: varmod-assign.mk,v 1.3 2020/08/25 18:59:30 rillig Exp $
|
||||
# $NetBSD: varmod-assign.mk,v 1.4 2020/08/25 20:49:40 rillig Exp $
|
||||
#
|
||||
# Tests for the obscure ::= variable modifiers, which perform variable
|
||||
# assignments during evaluation, just like the = operator in C.
|
||||
|
||||
all: mod-assign
|
||||
all: mod-assign-nested
|
||||
all: mod-assign-empty
|
||||
all: mod-assign-parse
|
||||
|
||||
mod-assign:
|
||||
# The ::?= modifier applies the ?= assignment operator 3 times.
|
||||
|
@ -46,3 +48,24 @@ mod-assign-nested:
|
|||
@echo $@: ${SINK4:Q}
|
||||
SINK3:= ${1:?${THEN3::=then3${IT3::=t3}}:${ELSE3::=else3${IE3::=e3}}}${THEN3}${ELSE3}${IT3}${IE3}
|
||||
SINK4:= ${0:?${THEN4::=then4${IT4::=t4}}:${ELSE4::=else4${IE4::=e4}}}${THEN4}${ELSE4}${IT4}${IE4}
|
||||
|
||||
mod-assign-empty:
|
||||
# Assigning to the empty variable would obviously not work since that variable
|
||||
# is write-protected. Therefore it is rejected early as a "bad modifier".
|
||||
@echo ${::=value}
|
||||
@echo $@: ${:Uvalue::=overwritten}
|
||||
|
||||
# The :L modifier sets the variable's value to its name.
|
||||
# Since the name is still "VAR", assigning to that variable works.
|
||||
@echo $@: ${VAR:L::=overwritten} VAR=${VAR}
|
||||
|
||||
mod-assign-parse:
|
||||
# The modifier for assignment operators starts with a ':'.
|
||||
# An 'x' after that is an invalid modifier.
|
||||
@echo ${ASSIGN::x} # 'x' is an unknown assignment operator
|
||||
|
||||
# When parsing an assignment operator fails because the operator is
|
||||
# incomplete, make falls back to the SysV modifier.
|
||||
@echo ${SYSV::=sysv\:x}${SYSV::x=:y}
|
||||
|
||||
@echo ${ASSIGN::=value # missing closing brace
|
||||
|
|
Loading…
Reference in New Issue