Module Name: src
Committed By: rillig
Date: Sun Jun 30 11:44:14 UTC 2024
Modified Files:
src/usr.bin/make: var.c
src/usr.bin/make/unit-tests: varmod-assign-shell.exp
varmod-assign-shell.mk varmod-assign.exp
Log Message:
make: sync error handling between '!=' assignment and '::!=' modifier
To generate a diff of this commit:
cvs rdiff -u -r1.1122 -r1.1123 src/usr.bin/make/var.c
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/varmod-assign-shell.exp \
src/usr.bin/make/unit-tests/varmod-assign-shell.mk
cvs rdiff -u -r1.21 -r1.22 src/usr.bin/make/unit-tests/varmod-assign.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.1122 src/usr.bin/make/var.c:1.1123
--- src/usr.bin/make/var.c:1.1122 Sun Jun 30 11:00:06 2024
+++ src/usr.bin/make/var.c Sun Jun 30 11:44:14 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.1122 2024/06/30 11:00:06 rillig Exp $ */
+/* $NetBSD: var.c,v 1.1123 2024/06/30 11:44:14 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -132,7 +132,7 @@
#include "metachar.h"
/* "@(#)var.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.1122 2024/06/30 11:00:06 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.1123 2024/06/30 11:44:14 rillig Exp $");
/*
* Variables are defined using one of the VAR=value assignments. Their
@@ -3557,7 +3557,7 @@ found_op:
char *output, *error;
output = Cmd_Exec(val.str, &error);
if (error != NULL) {
- Error("%s", error);
+ Parse_Error(PARSE_WARNING, "%s", error);
free(error);
} else
Var_Set(scope, expr->name, output);
Index: src/usr.bin/make/unit-tests/varmod-assign-shell.exp
diff -u src/usr.bin/make/unit-tests/varmod-assign-shell.exp:1.6 src/usr.bin/make/unit-tests/varmod-assign-shell.exp:1.7
--- src/usr.bin/make/unit-tests/varmod-assign-shell.exp:1.6 Sun Jun 30 11:37:21 2024
+++ src/usr.bin/make/unit-tests/varmod-assign-shell.exp Sun Jun 30 11:44:14 2024
@@ -1,10 +1,10 @@
-make: "varmod-assign-shell.mk" line 28: warning: Command "echo output; (exit 13)" exited with status 13
+make: "varmod-assign-shell.mk" line 21: warning: Command "echo output; (exit 13)" exited with status 13
Global: _ = # (empty)
Var_Parse: ${ASSIGNED::!=echo output; ${:U(exit 13)}} (eval-keep-dollar-and-undefined)
Evaluating modifier ${ASSIGNED::...} on value "previous" (eval-keep-dollar-and-undefined, regular)
Modifier part: "echo output; (exit 13)"
Capturing the output of command "echo output; (exit 13)"
-make: Command "echo output; (exit 13)" exited with status 13
+make: "varmod-assign-shell.mk" line 26: warning: while evaluating variable "ASSIGNED": Command "echo output; (exit 13)" exited with status 13
Result of ${ASSIGNED::!=echo output; ${:U(exit 13)}} is "" (eval-keep-dollar-and-undefined, regular)
Global: _ = # (empty)
Global: .MAKEFLAGS = -r -k -d v -d
Index: src/usr.bin/make/unit-tests/varmod-assign-shell.mk
diff -u src/usr.bin/make/unit-tests/varmod-assign-shell.mk:1.6 src/usr.bin/make/unit-tests/varmod-assign-shell.mk:1.7
--- src/usr.bin/make/unit-tests/varmod-assign-shell.mk:1.6 Sun Jun 30 11:37:21 2024
+++ src/usr.bin/make/unit-tests/varmod-assign-shell.mk Sun Jun 30 11:44:14 2024
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-assign-shell.mk,v 1.6 2024/06/30 11:37:21 rillig Exp $
+# $NetBSD: varmod-assign-shell.mk,v 1.7 2024/06/30 11:44:14 rillig Exp $
#
# Tests for the variable modifier '::!=', which assigns the output of a shell
# command to the variable, but only if the command exited successfully. This
@@ -15,20 +15,14 @@
# error message instead of the command that was executed. That's where the
# counterintuitive error message 'make: "previous" returned non-zero status'
# comes from.
-#
-# BUGS
-# Even though the variable modifier '::!=' produces an error message,
-# the exit status of make is still 0.
-#
-# Having an error message instead of a warning like for the variable
-# assignment operator '!=' is another unnecessary inconsistency.
DIRECT= previous
# expect+1: warning: Command "echo output; (exit 13)" exited with status 13
DIRECT!= echo output; (exit 13)
ASSIGNED= previous
-.MAKEFLAGS: -dv # to see the actual command
+.MAKEFLAGS: -dv # to see the "Capturing" debug output
+# expect+1: warning: while evaluating variable "ASSIGNED": Command "echo output; (exit 13)" exited with status 13
_:= ${ASSIGNED::!=echo output; ${:U(exit 13)}}
.MAKEFLAGS: -d0
Index: src/usr.bin/make/unit-tests/varmod-assign.exp
diff -u src/usr.bin/make/unit-tests/varmod-assign.exp:1.21 src/usr.bin/make/unit-tests/varmod-assign.exp:1.22
--- src/usr.bin/make/unit-tests/varmod-assign.exp:1.21 Sun Jun 30 11:37:21 2024
+++ src/usr.bin/make/unit-tests/varmod-assign.exp Sun Jun 30 11:44:14 2024
@@ -48,7 +48,7 @@ sysv:y
make: Unfinished modifier for "ASSIGN" ('}' missing)
ok=word
-make: Command " echo word; (exit 13) " exited with status 13
+make: warning: in target "mod-assign-shell-error": while evaluating variable "SH_ERR": Command " echo word; (exit 13) " exited with status 13
err=previous
Command: TARGET_CMD_VAR = cmd-value
Global: TARGET_GLOBAL_VAR = global-value