Module Name:    src
Committed By:   rillig
Date:           Sat Mar 29 10:39:49 UTC 2025

Modified Files:
        src/usr.bin/make: var.c
        src/usr.bin/make/unit-tests: check-expect.lua cmd-errors-jobs.exp
            cmd-errors-jobs.mk cmd-errors-lint.exp cmd-errors.exp lint.exp
            moderrs.exp var-recursive.exp var-recursive.mk varmisc.exp
            varmod-assign.exp varmod-hash.exp varmod-select-words.exp
            varmod-subst-regex.exp varmod-subst.exp

Log Message:
make: in stack traces from target commands, add the command level

A target can contain several commands, and these commands are likely to
contain the same expressions. To distinguish them, add one more line to
the stack trace, to narrow down the source of the error.


To generate a diff of this commit:
cvs rdiff -u -r1.1145 -r1.1146 src/usr.bin/make/var.c
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/check-expect.lua \
    src/usr.bin/make/unit-tests/cmd-errors-lint.exp \
    src/usr.bin/make/unit-tests/var-recursive.mk
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/make/unit-tests/cmd-errors-jobs.exp \
    src/usr.bin/make/unit-tests/cmd-errors.exp
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/make/unit-tests/cmd-errors-jobs.mk \
    src/usr.bin/make/unit-tests/var-recursive.exp
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/lint.exp
cvs rdiff -u -r1.45 -r1.46 src/usr.bin/make/unit-tests/moderrs.exp
cvs rdiff -u -r1.25 -r1.26 src/usr.bin/make/unit-tests/varmisc.exp
cvs rdiff -u -r1.30 -r1.31 src/usr.bin/make/unit-tests/varmod-assign.exp
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/varmod-hash.exp
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/varmod-select-words.exp
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/make/unit-tests/varmod-subst-regex.exp
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/varmod-subst.exp

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.1145 src/usr.bin/make/var.c:1.1146
--- src/usr.bin/make/var.c:1.1145	Sat Mar 22 12:23:00 2025
+++ src/usr.bin/make/var.c	Sat Mar 29 10:39:48 2025
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.1145 2025/03/22 12:23:00 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.1146 2025/03/29 10:39:48 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -128,7 +128,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.1145 2025/03/22 12:23:00 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.1146 2025/03/29 10:39:48 rillig Exp $");
 
 /*
  * Variables are defined using one of the VAR=value assignments.  Their
@@ -257,6 +257,7 @@ typedef struct SepBuf {
 
 typedef enum {
 	VSK_TARGET,
+	VSK_COMMAND,
 	VSK_VARNAME,
 	VSK_COND,
 	VSK_COND_THEN,
@@ -376,6 +377,7 @@ EvalStack_PrintDetails(void)
 	for (i = evalStack.len; i > 0; i--) {
 		static const char descr[][42] = {
 			"in target",
+			"in command",
 			"while evaluating variable",
 			"while evaluating condition",
 			"while evaluating then-branch of condition",
@@ -4766,8 +4768,10 @@ Var_SubstInTarget(const char *str, GNode
 {
 	char *res;
 	EvalStack_Push(VSK_TARGET, scope->name, NULL);
+	EvalStack_Push(VSK_COMMAND, str, NULL);
 	res = Var_Subst(str, scope, VARE_EVAL);
 	EvalStack_Pop();
+	EvalStack_Pop();
 	return res;
 }
 

Index: src/usr.bin/make/unit-tests/check-expect.lua
diff -u src/usr.bin/make/unit-tests/check-expect.lua:1.10 src/usr.bin/make/unit-tests/check-expect.lua:1.11
--- src/usr.bin/make/unit-tests/check-expect.lua:1.10	Sat Jan 11 20:16:40 2025
+++ src/usr.bin/make/unit-tests/check-expect.lua	Sat Mar 29 10:39:48 2025
@@ -1,5 +1,5 @@
 #!  /usr/bin/lua
--- $NetBSD: check-expect.lua,v 1.10 2025/01/11 20:16:40 rillig Exp $
+-- $NetBSD: check-expect.lua,v 1.11 2025/03/29 10:39:48 rillig Exp $
 
 --[[
 
@@ -23,6 +23,9 @@ expected text in the corresponding .exp 
 # expect-not: <substring>
         The substring must not occur as part of any line of the .exp file.
 
+# expect-not-matches: <pattern>
+        The pattern (see https://lua.org/manual/5.4/manual.html#6.4.1)
+        must not occur as part of any line of the .exp file.
 ]]
 
 
@@ -120,13 +123,24 @@ local function check_mk(mk_fname)
       end
     end
 
+    for text in mk_line:gmatch("#%s*expect%-not%-matches:%s*(.*)") do
+      local i = 1
+      while i <= #exp_lines and not exp_lines[i]:find(text, 1) do
+        i = i + 1
+      end
+      if i <= #exp_lines then
+        print_error("error: %s:%d: %s must not match '%s'",
+          mk_fname, mk_lineno, exp_fname, text)
+      end
+    end
+
     for text in mk_line:gmatch("#%s*expect:%s*(.*)") do
       local i = prev_expect_line
       -- As of 2022-04-15, some lines in the .exp files contain trailing
       -- whitespace.  If possible, this should be avoided by rewriting the
-      -- debug logging.  When done, the gsub can be removed.
+      -- debug logging.  When done, the trailing gsub can be removed.
       -- See deptgt-phony.exp lines 14 and 15.
-      while i < #exp_lines and text ~= exp_lines[i + 1]:gsub("%s*$", "") do
+      while i < #exp_lines and text ~= exp_lines[i + 1]:gsub("^%s*", ""):gsub("%s*$", "") do
         i = i + 1
       end
       if i < #exp_lines then
Index: src/usr.bin/make/unit-tests/cmd-errors-lint.exp
diff -u src/usr.bin/make/unit-tests/cmd-errors-lint.exp:1.10 src/usr.bin/make/unit-tests/cmd-errors-lint.exp:1.11
--- src/usr.bin/make/unit-tests/cmd-errors-lint.exp:1.10	Thu Aug 29 20:20:35 2024
+++ src/usr.bin/make/unit-tests/cmd-errors-lint.exp	Sat Mar 29 10:39:48 2025
@@ -1,11 +1,14 @@
 : undefined 
 make: Unclosed variable "UNCLOSED"
+	in command ": $@ ${UNCLOSED"
 	in target "unclosed-expression"
 make: Unclosed expression, expecting '}'
 	while evaluating variable "UNCLOSED" with value ""
+	in command ": $@ ${UNCLOSED:"
 	in target "unclosed-modifier"
 make: Unknown modifier "Z"
 	while evaluating variable "UNKNOWN" with value ""
+	in command ": $@ ${UNKNOWN:Z}"
 	in target "unknown-modifier"
 : end
 exit status 2
Index: src/usr.bin/make/unit-tests/var-recursive.mk
diff -u src/usr.bin/make/unit-tests/var-recursive.mk:1.10 src/usr.bin/make/unit-tests/var-recursive.mk:1.11
--- src/usr.bin/make/unit-tests/var-recursive.mk:1.10	Thu Aug 29 20:20:36 2024
+++ src/usr.bin/make/unit-tests/var-recursive.mk	Sat Mar 29 10:39:48 2025
@@ -1,4 +1,4 @@
-# $NetBSD: var-recursive.mk,v 1.10 2024/08/29 20:20:36 rillig Exp $
+# $NetBSD: var-recursive.mk,v 1.11 2025/03/29 10:39:48 rillig Exp $
 #
 # Tests for expressions that refer to themselves and thus cannot be
 # evaluated, as that would lead to an endless loop.
@@ -49,10 +49,10 @@ runtime:
 # expect: : before-recursive
 	: before-recursive
 # expect: make: Variable VAR is recursive.
-# expect-not: recursive-line-before
-# expect-not: recursive-line-after
+# expect-not-matches: ^: recursive-line-before
+# expect-not-matches: ^: recursive-line-after
 	: recursive-line-before <${VAR}> recursive-line-after
-# expect-not: after-recursive
+# expect-not-matches: ^: after-recursive
 	: after-recursive
 
 .else

Index: src/usr.bin/make/unit-tests/cmd-errors-jobs.exp
diff -u src/usr.bin/make/unit-tests/cmd-errors-jobs.exp:1.14 src/usr.bin/make/unit-tests/cmd-errors-jobs.exp:1.15
--- src/usr.bin/make/unit-tests/cmd-errors-jobs.exp:1.14	Thu Aug 29 20:20:35 2024
+++ src/usr.bin/make/unit-tests/cmd-errors-jobs.exp	Sat Mar 29 10:39:48 2025
@@ -8,23 +8,29 @@ end undefined-indirect with status 0
 
 begin parse-error-direct
 make: Unclosed variable "UNCLOSED"
+	in command ": unexpected $@-${UNCLOSED"
 	in target "parse-error-unclosed-expression"
 make: Unclosed expression, expecting '}'
 	while evaluating variable "UNCLOSED" with value ""
+	in command ": unexpected $@-${UNCLOSED:"
 	in target "parse-error-unclosed-modifier"
 make: Unknown modifier "Z"
 	while evaluating variable "UNKNOWN" with value ""
+	in command ": unexpected $@-${UNKNOWN:Z}-eol"
 	in target "parse-error-unknown-modifier"
 end parse-error-direct with status 2
 
 begin parse-error-indirect
 make: Unclosed variable "UNCLOSED"
+	in command ": unexpected $@-${UNCLOSED"
 	in target "parse-error-unclosed-expression"
 make: Unclosed expression, expecting '}'
 	while evaluating variable "UNCLOSED" with value ""
+	in command ": unexpected $@-${UNCLOSED:"
 	in target "parse-error-unclosed-modifier"
 make: Unknown modifier "Z"
 	while evaluating variable "UNKNOWN" with value ""
+	in command ": unexpected $@-${UNKNOWN:Z}-eol"
 	in target "parse-error-unknown-modifier"
 end parse-error-indirect with status 2
 
Index: src/usr.bin/make/unit-tests/cmd-errors.exp
diff -u src/usr.bin/make/unit-tests/cmd-errors.exp:1.14 src/usr.bin/make/unit-tests/cmd-errors.exp:1.15
--- src/usr.bin/make/unit-tests/cmd-errors.exp:1.14	Thu Aug 29 20:20:35 2024
+++ src/usr.bin/make/unit-tests/cmd-errors.exp	Sat Mar 29 10:39:48 2025
@@ -1,11 +1,14 @@
 : undefined--eol
 make: Unclosed variable "UNCLOSED"
+	in command ": $@-${UNCLOSED"
 	in target "unclosed-expression"
 make: Unclosed expression, expecting '}'
 	while evaluating variable "UNCLOSED" with value ""
+	in command ": $@-${UNCLOSED:"
 	in target "unclosed-modifier"
 make: Unknown modifier "Z"
 	while evaluating variable "UNKNOWN" with value ""
+	in command ": $@-${UNKNOWN:Z}-eol"
 	in target "unknown-modifier"
 : end-eol
 exit status 2

Index: src/usr.bin/make/unit-tests/cmd-errors-jobs.mk
diff -u src/usr.bin/make/unit-tests/cmd-errors-jobs.mk:1.13 src/usr.bin/make/unit-tests/cmd-errors-jobs.mk:1.14
--- src/usr.bin/make/unit-tests/cmd-errors-jobs.mk:1.13	Thu Aug 29 20:20:35 2024
+++ src/usr.bin/make/unit-tests/cmd-errors-jobs.mk	Sat Mar 29 10:39:48 2025
@@ -1,4 +1,4 @@
-# $NetBSD: cmd-errors-jobs.mk,v 1.13 2024/08/29 20:20:35 rillig Exp $
+# $NetBSD: cmd-errors-jobs.mk,v 1.14 2025/03/29 10:39:48 rillig Exp $
 #
 # Demonstrate how errors in expressions affect whether the commands
 # are actually executed in jobs mode.
@@ -47,8 +47,9 @@ parse-error-unclosed-modifier:
 parse-error-unknown-modifier:
 	: unexpected $@-${UNKNOWN:Z}-eol
 
-# expect-not: : unexpected
+# expect-not-matches: ^: unexpected
 # expect: make: Unclosed variable "UNCLOSED"
+# expect: in command ": unexpected $@-${UNCLOSED"
 # expect: make: Unclosed expression, expecting '}'
 # expect: make: Unknown modifier "Z"
 # expect: end parse-error-direct with status 2
Index: src/usr.bin/make/unit-tests/var-recursive.exp
diff -u src/usr.bin/make/unit-tests/var-recursive.exp:1.13 src/usr.bin/make/unit-tests/var-recursive.exp:1.14
--- src/usr.bin/make/unit-tests/var-recursive.exp:1.13	Thu Aug 29 20:20:36 2024
+++ src/usr.bin/make/unit-tests/var-recursive.exp	Sat Mar 29 10:39:48 2025
@@ -22,6 +22,7 @@ sub-exit status 1
 : before-recursive
 make: Variable VAR is recursive.
 	while evaluating variable "VAR" with value "${VAR}"
+	in command ": recursive-line-before <${VAR}> recursive-line-after"
 	in target "runtime"
 sub-exit status 2
 exit status 0

Index: src/usr.bin/make/unit-tests/lint.exp
diff -u src/usr.bin/make/unit-tests/lint.exp:1.7 src/usr.bin/make/unit-tests/lint.exp:1.8
--- src/usr.bin/make/unit-tests/lint.exp:1.7	Thu Aug 29 20:20:36 2024
+++ src/usr.bin/make/unit-tests/lint.exp	Sat Mar 29 10:39:48 2025
@@ -1,4 +1,5 @@
 make: In the :@ modifier, the variable name "${:Ubar:S,b,v,}" must not contain a dollar
 	while evaluating variable "VAR" with value "value"
+	in command "@echo ${VAR:Uvalue:@${:Ubar:S,b,v,}@x${var}y@:Q}"
 	in target "mod-loop-varname"
 exit status 2

Index: src/usr.bin/make/unit-tests/moderrs.exp
diff -u src/usr.bin/make/unit-tests/moderrs.exp:1.45 src/usr.bin/make/unit-tests/moderrs.exp:1.46
--- src/usr.bin/make/unit-tests/moderrs.exp:1.45	Thu Aug 29 20:20:36 2024
+++ src/usr.bin/make/unit-tests/moderrs.exp	Sat Mar 29 10:39:48 2025
@@ -1,140 +1,183 @@
 make: Unknown modifier "Z"
 	while evaluating variable "VAR" with value "TheVariable"
+	in command "@echo 'VAR:Z=before-${VAR:Z}-after'"
 	in target "mod-unknown-direct"
 make: Unknown modifier "Z"
 	while evaluating variable "VAR" with value "TheVariable"
+	in command "@echo 'VAR:${MOD_UNKN}=before-${VAR:${MOD_UNKN}:inner}-after'"
 	in target "mod-unknown-indirect"
 make: Unclosed expression, expecting '}' for modifier "S,V,v,"
 	while evaluating variable "VAR" with value "Thevariable"
+	in command "@echo VAR:S,V,v,=${VAR:S,V,v,"
 	in target "unclosed-direct"
 make: Unclosed expression after indirect modifier, expecting '}'
 	while evaluating variable "VAR" with value "Thevariable"
+	in command "@echo VAR:${MOD_TERM},=${VAR:${MOD_S}"
 	in target "unclosed-indirect"
 make: Unfinished modifier (',' missing)
 	while evaluating variable "VAR" with value "TheVariable"
+	in command "-@echo "VAR:${MOD_TERM}=${VAR:${MOD_TERM}}""
 	in target "unfinished-indirect"
 make: Unfinished modifier ('@' missing)
 	while evaluating variable "UNDEF" with value "1 2 3"
+	in command "@echo ${UNDEF:U1 2 3:@var}"
 	in target "unfinished-loop-1"
 make: Unfinished modifier ('@' missing)
 	while evaluating variable "UNDEF" with value "1 2 3"
+	in command "@echo ${UNDEF:U1 2 3:@var@...}"
 	in target "unfinished-loop-2"
 1 2 3
 make: Unclosed expression, expecting '}' for modifier "@var@${var}}...@"
 	while evaluating variable "UNDEF" with value "1}... 2}... 3}..."
+	in command "@echo ${UNDEF:U1 2 3:@var@${var}}...@"
 	in target "loop-close-1"
 1}... 2}... 3}...
 make: Unfinished modifier (']' missing)
 	while evaluating variable "UNDEF" with value "1 2 3"
+	in command "@echo ${UNDEF:U1 2 3:[}"
 	in target "words-1"
 make: Unfinished modifier (']' missing)
 	while evaluating variable "UNDEF" with value "1 2 3"
+	in command "@echo ${UNDEF:U1 2 3:[#}"
 	in target "words-2"
 13=
 make: Bad modifier ":[123451234512345123451234512345]"
 	while evaluating variable "UNDEF" with value "1 2 3"
+	in command "@echo 12345=${UNDEF:U1 2 3:[123451234512345123451234512345]:S,^$,ok,:S,^3$,ok,}"
 	in target "words-3"
 make: Unfinished modifier ('!' missing)
 	while evaluating variable "VARNAME" with value ""
+	in command "@echo ${VARNAME:!echo}"
 	in target "exclam-1"
 make: Unfinished modifier ('!' missing)
 	while evaluating variable "!" with value "!"
+	in command "@echo ${!:L:!=exclam}"
 	in target "exclam-2"
 make: Missing delimiter for modifier ':S'
 	while evaluating variable "VAR" with value "TheVariable"
+	in command "@echo 1: ${VAR:S"
 	in target "mod-subst-delimiter-1"
 make: Unfinished modifier (',' missing)
 	while evaluating variable "VAR" with value "TheVariable"
+	in command "@echo 2: ${VAR:S,"
 	in target "mod-subst-delimiter-2"
 make: Unfinished modifier (',' missing)
 	while evaluating variable "VAR" with value "TheVariable"
+	in command "@echo 3: ${VAR:S,from"
 	in target "mod-subst-delimiter-3"
 make: Unfinished modifier (',' missing)
 	while evaluating variable "VAR" with value "TheVariable"
+	in command "@echo 4: ${VAR:S,from,"
 	in target "mod-subst-delimiter-4"
 make: Unfinished modifier (',' missing)
 	while evaluating variable "VAR" with value "TheVariable"
+	in command "@echo 5: ${VAR:S,from,to"
 	in target "mod-subst-delimiter-5"
 make: Unclosed expression, expecting '}' for modifier "S,from,to,"
 	while evaluating variable "VAR" with value "TheVariable"
+	in command "@echo 6: ${VAR:S,from,to,"
 	in target "mod-subst-delimiter-6"
 7: TheVariable
 make: Missing delimiter for modifier ':C'
 	while evaluating variable "VAR" with value "TheVariable"
+	in command "@echo 1: ${VAR:C"
 	in target "mod-regex-delimiter-1"
 make: Unfinished modifier (',' missing)
 	while evaluating variable "VAR" with value "TheVariable"
+	in command "@echo 2: ${VAR:C,"
 	in target "mod-regex-delimiter-2"
 make: Unfinished modifier (',' missing)
 	while evaluating variable "VAR" with value "TheVariable"
+	in command "@echo 3: ${VAR:C,from"
 	in target "mod-regex-delimiter-3"
 make: Unfinished modifier (',' missing)
 	while evaluating variable "VAR" with value "TheVariable"
+	in command "@echo 4: ${VAR:C,from,"
 	in target "mod-regex-delimiter-4"
 make: Unfinished modifier (',' missing)
 	while evaluating variable "VAR" with value "TheVariable"
+	in command "@echo 5: ${VAR:C,from,to"
 	in target "mod-regex-delimiter-5"
 make: Unclosed expression, expecting '}' for modifier "C,from,to,"
 	while evaluating variable "VAR" with value "TheVariable"
+	in command "@echo 6: ${VAR:C,from,to,"
 	in target "mod-regex-delimiter-6"
 7: TheVariable
 112358132134
 15152535558513521534
 make: Bad modifier ":ts\65oct"
 	while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34"
+	in command "@echo ${FIB:ts\65oct}	# bad modifier"
 	in target "mod-ts-parse-3"
 make: Bad modifier ":ts\65oct"
 	while evaluating "${:U${FIB}:ts\65oct} # bad modifier, variable name is """ with value "1 1 2 3 5 8 13 21 34"
+	in command "@echo ${:U${FIB}:ts\65oct} # bad modifier, variable name is """
 	in target "mod-ts-parse-4"
 make: Bad modifier ":tsxy"
 	while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34"
+	in command "@echo ${FIB:tsxy}	# modifier too long"
 	in target "mod-ts-parse-5"
 make: Bad modifier ":t"
 	while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34"
+	in command "@echo ${FIB:t"
 	in target "mod-t-parse-1"
 make: Bad modifier ":txy"
 	while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34"
+	in command "@echo ${FIB:txy}"
 	in target "mod-t-parse-2"
 make: Bad modifier ":t"
 	while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34"
+	in command "@echo ${FIB:t}"
 	in target "mod-t-parse-3"
 make: Bad modifier ":t"
 	while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34"
+	in command "@echo ${FIB:t:M*}"
 	in target "mod-t-parse-4"
 make: Unfinished modifier (':' missing)
 	while evaluating then-branch of condition "FIB"
+	in command "@echo ${FIB:?"
 	in target "mod-ifelse-parse-1"
 make: Unfinished modifier (':' missing)
 	while evaluating then-branch of condition "FIB"
+	in command "@echo ${FIB:?then"
 	in target "mod-ifelse-parse-2"
 make: Unfinished modifier ('}' missing)
 	while evaluating else-branch of condition "FIB"
+	in command "@echo ${FIB:?then:"
 	in target "mod-ifelse-parse-3"
 make: Unfinished modifier ('}' missing)
 	while evaluating else-branch of condition "FIB"
+	in command "@echo ${FIB:?then:else"
 	in target "mod-ifelse-parse-4"
 then
 1 1 2 3 5 8 13 21 34
 make: Unknown modifier "__"
 	while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34"
+	in command "@echo ${FIB:__}		# modifier name too long"
 	in target "mod-remember-parse"
 make: Unknown modifier "3"
 	while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34"
+	in command "@echo ${FIB:3"
 	in target "mod-sysv-parse-1"
 make: Unclosed expression, expecting '}' for modifier "3"
 	while evaluating variable "FIB" with value ""
+	in command "@echo ${FIB:3"
 	in target "mod-sysv-parse-1"
 make: Unknown modifier "3="
 	while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34"
+	in command "@echo ${FIB:3="
 	in target "mod-sysv-parse-2"
 make: Unclosed expression, expecting '}' for modifier "3="
 	while evaluating variable "FIB" with value ""
+	in command "@echo ${FIB:3="
 	in target "mod-sysv-parse-2"
 make: Unknown modifier "3=x3"
 	while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34"
+	in command "@echo ${FIB:3=x3"
 	in target "mod-sysv-parse-3"
 make: Unclosed expression, expecting '}' for modifier "3=x3"
 	while evaluating variable "FIB" with value ""
+	in command "@echo ${FIB:3=x3"
 	in target "mod-sysv-parse-3"
 1 1 2 x3 5 8 1x3 21 34
 exit status 2

Index: src/usr.bin/make/unit-tests/varmisc.exp
diff -u src/usr.bin/make/unit-tests/varmisc.exp:1.25 src/usr.bin/make/unit-tests/varmisc.exp:1.26
--- src/usr.bin/make/unit-tests/varmisc.exp:1.25	Thu Aug 29 20:20:36 2024
+++ src/usr.bin/make/unit-tests/varmisc.exp	Sat Mar 29 10:39:48 2025
@@ -45,27 +45,36 @@ parse-dynamic: parse-dynamic parse-dynam
 parse-dynamic: parse-dynamic parse-dynamic after
 varerror-unclosed-1:begin
 make: Unclosed variable ""
+	in command "@echo $("
 	in target "varerror-unclosed-2"
 make: Unclosed variable "UNCLOSED"
+	in command "@echo $(UNCLOSED"
 	in target "varerror-unclosed-3"
 make: Unclosed variable "UNCLOSED"
+	in command "@echo ${UNCLOSED"
 	in target "varerror-unclosed-4"
 make: Unclosed variable "PATTERN"
 	while evaluating variable "UNCLOSED" with value ""
+	in command "@echo ${UNCLOSED:M${PATTERN"
 	in target "varerror-unclosed-5"
 make: Unclosed expression, expecting '}' for modifier "M${PATTERN"
 	while evaluating variable "UNCLOSED" with value ""
+	in command "@echo ${UNCLOSED:M${PATTERN"
 	in target "varerror-unclosed-5"
 make: Unclosed variable "param"
+	in command "@echo ${UNCLOSED.${param"
 	in target "varerror-unclosed-6"
 make: Unclosed variable "UNCLOSED."
+	in command "@echo ${UNCLOSED.${param"
 	in target "varerror-unclosed-6"
 
 make: Unclosed variable "UNCLOSED.1"
+	in command "@echo ${UNCLOSED.${:U1}"
 	in target "varerror-unclosed-7"
 make: Unclosed variable "UNCLOSED_ORIG"
 	while evaluating variable "UNCLOSED_INDIR_1" with value "${UNCLOSED_ORIG"
 	while evaluating variable "UNCLOSED_INDIR_2" with value "${UNCLOSED_INDIR_1}"
+	in command "@echo ${UNCLOSED_INDIR_2}"
 	in target "varerror-unclosed-8"
 target1-flags: we have: one two
 target2-flags: we have: one two three four

Index: src/usr.bin/make/unit-tests/varmod-assign.exp
diff -u src/usr.bin/make/unit-tests/varmod-assign.exp:1.30 src/usr.bin/make/unit-tests/varmod-assign.exp:1.31
--- src/usr.bin/make/unit-tests/varmod-assign.exp:1.30	Sat Jan 11 21:21:34 2025
+++ src/usr.bin/make/unit-tests/varmod-assign.exp	Sat Mar 29 10:39:48 2025
@@ -39,17 +39,21 @@ Global: .MAKEFLAGS =  -r -k -d v -d 0 -d
 Global: .MAKEFLAGS =  -r -k -d v -d 0 -d v -d 0
 make: Bad modifier ":"
 	while evaluating "${::=value}" with value ""
+	in command "@echo $@: ${::=value}"
 	in target "mod-assign-empty-1"
 make: Bad modifier ":"
 	while evaluating "${:Uvalue::=overwritten}" with value "value"
+	in command "@echo $@: ${:Uvalue::=overwritten}"
 	in target "mod-assign-empty-2"
 mod-assign-empty-3: VAR=overwritten
 make: Unknown modifier ":x"
 	while evaluating variable "ASSIGN" with value ""
+	in command "@echo ${ASSIGN::x}"
 	in target "mod-assign-parse-1"
 sysv:y
 make: Unfinished modifier ('}' missing)
 	while evaluating variable "ASSIGN" with value ""
+	in command "@echo ${ASSIGN::=value	# missing closing brace"
 	in target "mod-assign-parse-3"
 ok=word
 make: warning: Command " echo word; (exit 13) " exited with status 13

Index: src/usr.bin/make/unit-tests/varmod-hash.exp
diff -u src/usr.bin/make/unit-tests/varmod-hash.exp:1.8 src/usr.bin/make/unit-tests/varmod-hash.exp:1.9
--- src/usr.bin/make/unit-tests/varmod-hash.exp:1.8	Thu Aug 29 20:20:36 2024
+++ src/usr.bin/make/unit-tests/varmod-hash.exp	Sat Mar 29 10:39:49 2025
@@ -1,12 +1,15 @@
 make: Unknown modifier "has"
 	while evaluating variable "12345" with value "12345"
+	in command "@echo ${12345:L:has}			# modifier name too short"
 	in target "step-1"
 26bb0f5f
 12345
 make: Unknown modifier "hasX"
 	while evaluating variable "12345" with value "12345"
+	in command "@echo ${12345:L:hasX}			# misspelled"
 	in target "step-4"
 make: Unknown modifier "hashed"
 	while evaluating variable "12345" with value "12345"
+	in command "@echo ${12345:L:hashed}			# modifier name too long"
 	in target "step-5"
 exit status 2

Index: src/usr.bin/make/unit-tests/varmod-select-words.exp
diff -u src/usr.bin/make/unit-tests/varmod-select-words.exp:1.6 src/usr.bin/make/unit-tests/varmod-select-words.exp:1.7
--- src/usr.bin/make/unit-tests/varmod-select-words.exp:1.6	Thu Aug 29 20:20:36 2024
+++ src/usr.bin/make/unit-tests/varmod-select-words.exp	Sat Mar 29 10:39:49 2025
@@ -1,5 +1,6 @@
 make: Bad modifier ":[]"
 	while evaluating variable "LIST" with value "one two three four five six"
+	in command "@echo 'LIST:[]="${LIST:[]}" is an error'"
 	in target "mod-squarebrackets-empty"
 LIST:[0]="one two three four five six"
 LIST:[0x0]="one two three four five six"
@@ -40,9 +41,11 @@ REALLYSPACE:[*]:[1]=" " == " " ?
 LIST:[1]="one"
 make: Bad modifier ":[1.]"
 	while evaluating variable "LIST" with value "one two three four five six"
+	in command "@echo 'LIST:[1.]="${LIST:[1.]}" is an error'"
 	in target "mod-squarebrackets-n-error-1"
 make: Bad modifier ":[1]."
 	while evaluating variable "LIST" with value "one two three four five six"
+	in command "@echo 'LIST:[1].="${LIST:[1].}" is an error'"
 	in target "mod-squarebrackets-n-error-2"
 LIST:[2]="two"
 LIST:[6]="six"
@@ -50,9 +53,11 @@ LIST:[7]=""
 LIST:[999]=""
 make: Bad modifier ":[-]"
 	while evaluating variable "LIST" with value "one two three four five six"
+	in command "@echo 'LIST:[-]="${LIST:[-]}" is an error'"
 	in target "mod-squarebrackets-n-error-3"
 make: Bad modifier ":[--]"
 	while evaluating variable "LIST" with value "one two three four five six"
+	in command "@echo 'LIST:[--]="${LIST:[--]}" is an error'"
 	in target "mod-squarebrackets-n-error-4"
 LIST:[-1]="six"
 LIST:[-2]="five"
@@ -74,16 +79,20 @@ LIST:[*]:C/ /,/:[@]:[2]="three"
 LONGLIST:[012..0x12]="10 11 12 13 14 15 16 17 18"
 make: Bad modifier ":[1.]"
 	while evaluating variable "LIST" with value "one two three four five six"
+	in command "@echo 'LIST:[1.]="${LIST:[1.]}" is an error'"
 	in target "mod-squarebrackets-start-end-error-1"
 make: Bad modifier ":[1..]"
 	while evaluating variable "LIST" with value "one two three four five six"
+	in command "@echo 'LIST:[1..]="${LIST:[1..]}" is an error'"
 	in target "mod-squarebrackets-start-end-error-2"
 make: Bad modifier ":[1.. ]"
 	while evaluating variable "LIST" with value "one two three four five six"
+	in command "@echo 'LIST:[1.. ]="${LIST:[1.. ]}" is an error'"
 	in target "mod-squarebrackets-start-end-error-3"
 LIST:[1..1]="one"
 make: Bad modifier ":[1..1.]"
 	while evaluating variable "LIST" with value "one two three four five six"
+	in command "@echo 'LIST:[1..1.]="${LIST:[1..1.]}" is an error'"
 	in target "mod-squarebrackets-start-end-error-4"
 LIST:[1..2]="one two"
 LIST:[2..1]="two one"
@@ -91,9 +100,11 @@ LIST:[3..-2]="three four five"
 LIST:[-4..4]="three four"
 make: Bad modifier ":[0..1]"
 	while evaluating variable "LIST" with value "one two three four five six"
+	in command "@echo 'LIST:[0..1]="${LIST:[0..1]}" is an error'"
 	in target "mod-squarebrackets-start-end-error-5"
 make: Bad modifier ":[-1..0]"
 	while evaluating variable "LIST" with value "one two three four five six"
+	in command "@echo 'LIST:[-1..0]="${LIST:[-1..0]}" is an error'"
 	in target "mod-squarebrackets-start-end-error-6"
 LIST:[-1..1]="six five four three two one"
 LIST:[0..0]="one two three four five six"
@@ -110,6 +121,7 @@ LIST:[${STAR}]="one two three four five 
 LIST:[${AT}]="one two three four five six"
 make: Bad modifier ":[${EMPTY"
 	while evaluating variable "LIST" with value "one two three four five six"
+	in command "@echo 'LIST:[$${EMPTY}]="${LIST:[${EMPTY}]}" is an error'"
 	in target "mod-squarebrackets-nested-error-1"
 LIST:[${LONGLIST:[21]:S/2//}]="one"
 LIST:[${LIST:[#]}]="six"

Index: src/usr.bin/make/unit-tests/varmod-subst-regex.exp
diff -u src/usr.bin/make/unit-tests/varmod-subst-regex.exp:1.12 src/usr.bin/make/unit-tests/varmod-subst-regex.exp:1.13
--- src/usr.bin/make/unit-tests/varmod-subst-regex.exp:1.12	Thu Aug 29 20:20:37 2024
+++ src/usr.bin/make/unit-tests/varmod-subst-regex.exp	Sat Mar 29 10:39:49 2025
@@ -1,51 +1,66 @@
 make: Regex compilation error: (details omitted)
 	while evaluating "${:Uword1 word2:C,****,____,g:C,word,____,:Q}." with value "word1 word2"
+	in command "@echo $@: ${:Uword1 word2:C,****,____,g:C,word,____,:Q}."
 	in target "mod-regex-compile-error"
 make: No subexpression \1
 	while evaluating "${:U1 23 456:C,..,\1\1,:Q}" with value "1 23 456"
+	in command "@echo $@:11-missing:${:U1 23 456:C,..,\1\1,:Q}"
 	in target "mod-regex-limits-1"
 make: No subexpression \1
 	while evaluating "${:U1 23 456:C,..,\1\1,:Q}" with value "1 23 456"
+	in command "@echo $@:11-missing:${:U1 23 456:C,..,\1\1,:Q}"
 	in target "mod-regex-limits-1"
 make: No subexpression \1
 	while evaluating "${:U1 23 456:C,..,\1\1,:Q}" with value "1 23 456"
+	in command "@echo $@:11-missing:${:U1 23 456:C,..,\1\1,:Q}"
 	in target "mod-regex-limits-1"
 make: No subexpression \1
 	while evaluating "${:U1 23 456:C,..,\1\1,:Q}" with value "1 23 456"
+	in command "@echo $@:11-missing:${:U1 23 456:C,..,\1\1,:Q}"
 	in target "mod-regex-limits-1"
 mod-regex-limits-2:11-ok:1 22 446
 make: No subexpression \2
 	while evaluating "${:U1 23 456:C,..,\2\2,:Q}" with value "1 23 456"
+	in command "@echo $@:22-missing:${:U1 23 456:C,..,\2\2,:Q}"
 	in target "mod-regex-limits-3"
 make: No subexpression \2
 	while evaluating "${:U1 23 456:C,..,\2\2,:Q}" with value "1 23 456"
+	in command "@echo $@:22-missing:${:U1 23 456:C,..,\2\2,:Q}"
 	in target "mod-regex-limits-3"
 make: No subexpression \2
 	while evaluating "${:U1 23 456:C,..,\2\2,:Q}" with value "1 23 456"
+	in command "@echo $@:22-missing:${:U1 23 456:C,..,\2\2,:Q}"
 	in target "mod-regex-limits-3"
 make: No subexpression \2
 	while evaluating "${:U1 23 456:C,..,\2\2,:Q}" with value "1 23 456"
+	in command "@echo $@:22-missing:${:U1 23 456:C,..,\2\2,:Q}"
 	in target "mod-regex-limits-3"
 make: No subexpression \2
 	while evaluating "${:U1 23 456:C,(.).,\2\2,:Q}" with value "1 23 456"
+	in command "@echo $@:22-missing:${:U1 23 456:C,(.).,\2\2,:Q}"
 	in target "mod-regex-limits-4"
 make: No subexpression \2
 	while evaluating "${:U1 23 456:C,(.).,\2\2,:Q}" with value "1 23 456"
+	in command "@echo $@:22-missing:${:U1 23 456:C,(.).,\2\2,:Q}"
 	in target "mod-regex-limits-4"
 make: No subexpression \2
 	while evaluating "${:U1 23 456:C,(.).,\2\2,:Q}" with value "1 23 456"
+	in command "@echo $@:22-missing:${:U1 23 456:C,(.).,\2\2,:Q}"
 	in target "mod-regex-limits-4"
 make: No subexpression \2
 	while evaluating "${:U1 23 456:C,(.).,\2\2,:Q}" with value "1 23 456"
+	in command "@echo $@:22-missing:${:U1 23 456:C,(.).,\2\2,:Q}"
 	in target "mod-regex-limits-4"
 mod-regex-limits-5:22-ok:1 33 556
 mod-regex-limits-6:capture:ihgfedcbaabcdefghijABCDEFGHIJa0a1a2rest
 make: Regex compilation error: (details omitted)
 	while evaluating variable "UNDEF" with value "value"
+	in command "@echo $@: ${UNDEF:Uvalue:C,[,,}"
 	in target "mod-regex-errors-1"
 make: Unknown modifier "Z"
 	while evaluating "${:U:Z}y,W}" with value ""
 	while evaluating variable "word" with value "word"
+	in command "@echo $@: ${word:L:C,.*,x${:U:Z}y,W}"
 	in target "mod-regex-errors-2"
 unmatched-subexpression.ok: one one 2 3 5 8 one3 2one 34
 make: No match for subexpression \2

Index: src/usr.bin/make/unit-tests/varmod-subst.exp
diff -u src/usr.bin/make/unit-tests/varmod-subst.exp:1.9 src/usr.bin/make/unit-tests/varmod-subst.exp:1.10
--- src/usr.bin/make/unit-tests/varmod-subst.exp:1.9	Thu Aug 29 20:20:37 2024
+++ src/usr.bin/make/unit-tests/varmod-subst.exp	Sat Mar 29 10:39:49 2025
@@ -47,6 +47,7 @@ mod-subst-chain:
 A B c.
 make: Unknown modifier "i"
 	while evaluating "${:Uvalue:S,a,x,i}." with value "vxlue"
+	in command "@echo ${:Uvalue:S,a,x,i}."
 	in target "mod-subst-chain"
 mod-subst-dollar:$1:
 mod-subst-dollar:$2:

Reply via email to