diff --git a/usr.bin/make/unit-tests/varmod-remember.mk b/usr.bin/make/unit-tests/varmod-remember.mk index 403811759672..5955a428036a 100644 --- a/usr.bin/make/unit-tests/varmod-remember.mk +++ b/usr.bin/make/unit-tests/varmod-remember.mk @@ -1,8 +1,14 @@ -# $NetBSD: varmod-remember.mk,v 1.6 2021/03/14 17:27:27 rillig Exp $ +# $NetBSD: varmod-remember.mk,v 1.7 2023/02/09 07:34:15 sjg Exp $ # # Tests for the :_ modifier, which saves the current variable value # in the _ variable or another, to be used later again. +# this should result in "1=A 2=B 3=C" +ABC= ${A B C:L:_:range:@i@$i=${_:[$i]}@} + +# we compare this with a repeat later +x:= ${ABC} + .if ${1 2 3:L:_:@var@${_}@} != "1 2 3 1 2 3 1 2 3" . error .endif @@ -32,4 +38,10 @@ S= INDIRECT_VARNAME . error .endif +# we *should* get the same result as for $x above +X:= ${ABC} +.if $X != $x +. error +.endif + all: diff --git a/usr.bin/make/var.c b/usr.bin/make/var.c index 1ed96e123e89..cd35e155ad5b 100644 --- a/usr.bin/make/var.c +++ b/usr.bin/make/var.c @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.1039 2023/01/26 20:48:17 sjg Exp $ */ +/* $NetBSD: var.c,v 1.1040 2023/02/09 07:34:15 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -139,7 +139,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.1039 2023/01/26 20:48:17 sjg Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.1040 2023/02/09 07:34:15 sjg Exp $"); /* * Variables are defined using one of the VAR=value assignments. Their @@ -3578,7 +3578,7 @@ ApplyModifier_Remember(const char **pp, ModChain *ch) *pp = mod + 1; if (Expr_ShouldEval(expr)) - Var_Set(expr->scope, name.str, Expr_Str(expr)); + Var_Set(SCOPE_GLOBAL, name.str, Expr_Str(expr)); FStr_Done(&name); return AMR_OK;