Module Name:    src
Committed By:   rillig
Date:           Tue Nov 17 20:11:02 UTC 2020

Modified Files:
        src/usr.bin/make: var.c
        src/usr.bin/make/unit-tests: varmod-shell.exp varmod-shell.mk

Log Message:
make(1): fix error message of failed :!cmd! modifier (since 2000-04-29)


To generate a diff of this commit:
cvs rdiff -u -r1.688 -r1.689 src/usr.bin/make/var.c
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/varmod-shell.exp
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/varmod-shell.mk

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.688 src/usr.bin/make/var.c:1.689
--- src/usr.bin/make/var.c:1.688	Mon Nov 16 21:39:22 2020
+++ src/usr.bin/make/var.c	Tue Nov 17 20:11:02 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.688 2020/11/16 21:39:22 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.689 2020/11/17 20:11:02 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -130,7 +130,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.688 2020/11/16 21:39:22 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.689 2020/11/17 20:11:02 rillig Exp $");
 
 #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
 #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -2308,10 +2308,9 @@ ApplyModifier_ShellCommand(const char **
 	st->newVal = Cmd_Exec(cmd, &errfmt);
     else
 	st->newVal = bmake_strdup("");
-    free(cmd);
-
     if (errfmt != NULL)
-	Error(errfmt, st->val);	/* XXX: why still return AMR_OK? */
+	Error(errfmt, cmd);	/* XXX: why still return AMR_OK? */
+    free(cmd);
 
     ApplyModifiersState_Define(st);
     return AMR_OK;

Index: src/usr.bin/make/unit-tests/varmod-shell.exp
diff -u src/usr.bin/make/unit-tests/varmod-shell.exp:1.2 src/usr.bin/make/unit-tests/varmod-shell.exp:1.3
--- src/usr.bin/make/unit-tests/varmod-shell.exp:1.2	Tue Nov 17 20:08:09 2020
+++ src/usr.bin/make/unit-tests/varmod-shell.exp	Tue Nov 17 20:11:02 2020
@@ -1,3 +1,3 @@
-make: "" returned non-zero status
-make: "previous value" returned non-zero status
+make: "echo word; false" returned non-zero status
+make: "echo word; false" returned non-zero status
 exit status 0

Index: src/usr.bin/make/unit-tests/varmod-shell.mk
diff -u src/usr.bin/make/unit-tests/varmod-shell.mk:1.4 src/usr.bin/make/unit-tests/varmod-shell.mk:1.5
--- src/usr.bin/make/unit-tests/varmod-shell.mk:1.4	Tue Nov 17 20:08:09 2020
+++ src/usr.bin/make/unit-tests/varmod-shell.mk	Tue Nov 17 20:11:02 2020
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-shell.mk,v 1.4 2020/11/17 20:08:09 rillig Exp $
+# $NetBSD: varmod-shell.mk,v 1.5 2020/11/17 20:11:02 rillig Exp $
 #
 # Tests for the :sh variable modifier, which runs the shell command
 # given by the variable value and returns its output.
@@ -20,7 +20,7 @@
 # If the command exits with non-zero, an error message is printed.
 # XXX: Processing continues as usual though.
 #
-# Since 2000-04-29, the error message mentions the previous
+# Between 2000-04-29 and 2020-11-17, the error message mentioned the previous
 # value of the expression (which is usually an empty string) instead of the
 # command that was executed.  It's strange that such a simple bug could
 # survive such a long time.

Reply via email to