Module Name: src
Committed By: rillig
Date: Tue Jul 9 19:43:02 UTC 2024
Modified Files:
src/usr.bin/make: main.c make.h parse.c
src/usr.bin/make/unit-tests: cmd-errors-jobs.exp cmd-errors-jobs.mk
cmd-errors.exp cmd-errors.mk dep-var.exp moderrs.exp varmisc.exp
varmod-assign.exp varmod-hash.exp varmod-select-words.exp
varmod-subst.exp
Log Message:
make: error out on parse/evaluation errors in shell commands
The expression ${VAR:X} has an unknown modifier ':X'. Previously, this
expression errored out when the expression was evaluated at parse time,
but not when the expression was evaluated when generating the commands
to bring a target up to date. The errors were previously reported, they
didn't affect the exit status, though.
Now, errors in expressions are handled in the same way, regardless of
the time at which they are evaluated.
To generate a diff of this commit:
cvs rdiff -u -r1.630 -r1.631 src/usr.bin/make/main.c
cvs rdiff -u -r1.342 -r1.343 src/usr.bin/make/make.h
cvs rdiff -u -r1.733 -r1.734 src/usr.bin/make/parse.c
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/cmd-errors-jobs.exp \
src/usr.bin/make/unit-tests/cmd-errors.mk
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/cmd-errors-jobs.mk \
src/usr.bin/make/unit-tests/dep-var.exp
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/cmd-errors.exp
cvs rdiff -u -r1.41 -r1.42 src/usr.bin/make/unit-tests/moderrs.exp
cvs rdiff -u -r1.22 -r1.23 src/usr.bin/make/unit-tests/varmisc.exp
cvs rdiff -u -r1.26 -r1.27 src/usr.bin/make/unit-tests/varmod-assign.exp
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/varmod-hash.exp
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/varmod-select-words.exp
cvs rdiff -u -r1.6 -r1.7 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/main.c
diff -u src/usr.bin/make/main.c:1.630 src/usr.bin/make/main.c:1.631
--- src/usr.bin/make/main.c:1.630 Sun Jul 7 09:54:12 2024
+++ src/usr.bin/make/main.c Tue Jul 9 19:43:01 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.630 2024/07/07 09:54:12 rillig Exp $ */
+/* $NetBSD: main.c,v 1.631 2024/07/09 19:43:01 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -111,7 +111,7 @@
#include "trace.h"
/* "@(#)main.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: main.c,v 1.630 2024/07/07 09:54:12 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.631 2024/07/09 19:43:01 rillig Exp $");
#if defined(MAKE_NATIVE)
__COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
"The Regents of the University of California. "
@@ -1604,7 +1604,7 @@ main_CleanUp(void)
static int
main_Exit(bool outOfDate)
{
- if (opts.strict && (main_errors > 0 || Parse_NumErrors() > 0))
+ if ((opts.strict && main_errors > 0) || parseErrors > 0)
return 2; /* Not 1 so -q can distinguish error */
return outOfDate ? 1 : 0;
}
Index: src/usr.bin/make/make.h
diff -u src/usr.bin/make/make.h:1.342 src/usr.bin/make/make.h:1.343
--- src/usr.bin/make/make.h:1.342 Sun Jul 7 09:54:12 2024
+++ src/usr.bin/make/make.h Tue Jul 9 19:43:01 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: make.h,v 1.342 2024/07/07 09:54:12 rillig Exp $ */
+/* $NetBSD: make.h,v 1.343 2024/07/09 19:43:01 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -861,6 +861,7 @@ const char *cached_realpath(const char *
bool GetBooleanExpr(const char *, bool);
/* parse.c */
+extern int parseErrors;
void Parse_Init(void);
#ifdef CLEANUP
void Parse_End(void);
@@ -874,7 +875,6 @@ void Parse_File(const char *, int);
void Parse_PushInput(const char *, unsigned, unsigned, Buffer,
struct ForLoop *);
void Parse_MainName(GNodeList *);
-int Parse_NumErrors(void) MAKE_ATTR_USE;
unsigned int CurFile_CondMinDepth(void) MAKE_ATTR_USE;
void Parse_GuardElse(void);
void Parse_GuardEndif(void);
Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.733 src/usr.bin/make/parse.c:1.734
--- src/usr.bin/make/parse.c:1.733 Sun Jul 7 07:50:57 2024
+++ src/usr.bin/make/parse.c Tue Jul 9 19:43:01 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.733 2024/07/07 07:50:57 rillig Exp $ */
+/* $NetBSD: parse.c,v 1.734 2024/07/09 19:43:01 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -105,7 +105,7 @@
#include "pathnames.h"
/* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: parse.c,v 1.733 2024/07/07 07:50:57 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.734 2024/07/09 19:43:01 rillig Exp $");
/* Detects a multiple-inclusion guard in a makefile. */
typedef enum {
@@ -231,7 +231,7 @@ static StringList targCmds = LST_INIT;
*/
static GNode *order_pred;
-static int parseErrors;
+int parseErrors;
/*
* The include chain of makefiles. At index 0 is the top-level makefile from
@@ -3012,9 +3012,3 @@ Parse_MainName(GNodeList *mainList)
Global_Append(".TARGETS", mainNode->name);
}
-
-int
-Parse_NumErrors(void)
-{
- return parseErrors;
-}
Index: src/usr.bin/make/unit-tests/cmd-errors-jobs.exp
diff -u src/usr.bin/make/unit-tests/cmd-errors-jobs.exp:1.8 src/usr.bin/make/unit-tests/cmd-errors-jobs.exp:1.9
--- src/usr.bin/make/unit-tests/cmd-errors-jobs.exp:1.8 Fri Jul 5 18:59:33 2024
+++ src/usr.bin/make/unit-tests/cmd-errors-jobs.exp Tue Jul 9 19:43:01 2024
@@ -6,4 +6,4 @@ make: in target "unclosed-modifier": whi
make: in target "unknown-modifier": while evaluating variable "UNKNOWN" with value "": Unknown modifier "Z"
: unknown-modifier--eol
: end-eol
-exit status 0
+exit status 2
Index: src/usr.bin/make/unit-tests/cmd-errors.mk
diff -u src/usr.bin/make/unit-tests/cmd-errors.mk:1.8 src/usr.bin/make/unit-tests/cmd-errors.mk:1.9
--- src/usr.bin/make/unit-tests/cmd-errors.mk:1.8 Fri Jul 5 18:59:33 2024
+++ src/usr.bin/make/unit-tests/cmd-errors.mk Tue Jul 9 19:43:01 2024
@@ -1,4 +1,4 @@
-# $NetBSD: cmd-errors.mk,v 1.8 2024/07/05 18:59:33 rillig Exp $
+# $NetBSD: cmd-errors.mk,v 1.9 2024/07/09 19:43:01 rillig Exp $
#
# Demonstrate how errors in expressions affect whether the commands
# are actually executed in compat mode.
@@ -33,5 +33,4 @@ end:
# expect: : end-eol
: $@-eol
-# XXX: Despite the parse errors, the exit status is 0.
-# expect: exit status 0
+# expect: 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.7 src/usr.bin/make/unit-tests/cmd-errors-jobs.mk:1.8
--- src/usr.bin/make/unit-tests/cmd-errors-jobs.mk:1.7 Fri Jul 5 18:59:33 2024
+++ src/usr.bin/make/unit-tests/cmd-errors-jobs.mk Tue Jul 9 19:43:01 2024
@@ -1,4 +1,4 @@
-# $NetBSD: cmd-errors-jobs.mk,v 1.7 2024/07/05 18:59:33 rillig Exp $
+# $NetBSD: cmd-errors-jobs.mk,v 1.8 2024/07/09 19:43:01 rillig Exp $
#
# Demonstrate how errors in expressions affect whether the commands
# are actually executed in jobs mode.
@@ -35,5 +35,4 @@ unknown-modifier:
end:
: $@-eol
-# XXX: Despite the parse errors, the exit status is 0.
-# expect: exit status 0
+# expect: exit status 2
Index: src/usr.bin/make/unit-tests/dep-var.exp
diff -u src/usr.bin/make/unit-tests/dep-var.exp:1.7 src/usr.bin/make/unit-tests/dep-var.exp:1.8
--- src/usr.bin/make/unit-tests/dep-var.exp:1.7 Sun Jun 2 15:31:26 2024
+++ src/usr.bin/make/unit-tests/dep-var.exp Tue Jul 9 19:43:01 2024
@@ -27,4 +27,4 @@ def2
a-def2-b
1-2-NDIRECT_2-2-1
)
-exit status 0
+exit status 2
Index: src/usr.bin/make/unit-tests/cmd-errors.exp
diff -u src/usr.bin/make/unit-tests/cmd-errors.exp:1.11 src/usr.bin/make/unit-tests/cmd-errors.exp:1.12
--- src/usr.bin/make/unit-tests/cmd-errors.exp:1.11 Fri Jul 5 18:59:33 2024
+++ src/usr.bin/make/unit-tests/cmd-errors.exp Tue Jul 9 19:43:01 2024
@@ -6,4 +6,4 @@ make: in target "unclosed-modifier": whi
make: in target "unknown-modifier": while evaluating variable "UNKNOWN" with value "": Unknown modifier "Z"
: unknown-modifier--eol
: end-eol
-exit status 0
+exit status 2
Index: src/usr.bin/make/unit-tests/moderrs.exp
diff -u src/usr.bin/make/unit-tests/moderrs.exp:1.41 src/usr.bin/make/unit-tests/moderrs.exp:1.42
--- src/usr.bin/make/unit-tests/moderrs.exp:1.41 Fri Jul 5 19:47:22 2024
+++ src/usr.bin/make/unit-tests/moderrs.exp Tue Jul 9 19:43:01 2024
@@ -112,4 +112,4 @@ make: in target "mod-sysv-parse": while
1 1 2 x3 5 8 1x3 21 34
-exit status 0
+exit status 2
Index: src/usr.bin/make/unit-tests/varmisc.exp
diff -u src/usr.bin/make/unit-tests/varmisc.exp:1.22 src/usr.bin/make/unit-tests/varmisc.exp:1.23
--- src/usr.bin/make/unit-tests/varmisc.exp:1.22 Fri Jul 5 18:59:33 2024
+++ src/usr.bin/make/unit-tests/varmisc.exp Tue Jul 9 19:43:01 2024
@@ -68,4 +68,4 @@ make: in target "varerror-unclosed": whi
varerror-unclosed:end
target1-flags: we have: one two
target2-flags: we have: one two three four
-exit status 0
+exit status 2
Index: src/usr.bin/make/unit-tests/varmod-assign.exp
diff -u src/usr.bin/make/unit-tests/varmod-assign.exp:1.26 src/usr.bin/make/unit-tests/varmod-assign.exp:1.27
--- src/usr.bin/make/unit-tests/varmod-assign.exp:1.26 Fri Jul 5 19:47:22 2024
+++ src/usr.bin/make/unit-tests/varmod-assign.exp Tue Jul 9 19:43:01 2024
@@ -57,4 +57,4 @@ target: TARGET_TARGET_VAR = new-value
Global: TARGET_GLOBAL_VAR = new-value
Global: TARGET_ENV_VAR = new-value
target: TARGET_NEW_VAR = new-value
-exit status 0
+exit status 2
Index: src/usr.bin/make/unit-tests/varmod-hash.exp
diff -u src/usr.bin/make/unit-tests/varmod-hash.exp:1.5 src/usr.bin/make/unit-tests/varmod-hash.exp:1.6
--- src/usr.bin/make/unit-tests/varmod-hash.exp:1.5 Thu Jul 4 17:47:54 2024
+++ src/usr.bin/make/unit-tests/varmod-hash.exp Tue Jul 9 19:43:01 2024
@@ -6,4 +6,4 @@ make: in target "all": while evaluating
make: in target "all": while evaluating variable "12345" with value "12345": Unknown modifier "hashed"
-exit status 0
+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.3 src/usr.bin/make/unit-tests/varmod-select-words.exp:1.4
--- src/usr.bin/make/unit-tests/varmod-select-words.exp:1.3 Thu Jul 4 18:53:37 2024
+++ src/usr.bin/make/unit-tests/varmod-select-words.exp Tue Jul 9 19:43:01 2024
@@ -123,4 +123,4 @@ LIST:tw:C/ /,/g="one two three four five
LIST:tw:C/ /,/1g="one two three four five six"
LIST:tw:tW:C/ /,/="one,two three four five six"
LIST:tW:tw:C/ /,/="one two three four five six"
-exit status 0
+exit status 2
Index: src/usr.bin/make/unit-tests/varmod-subst.exp
diff -u src/usr.bin/make/unit-tests/varmod-subst.exp:1.6 src/usr.bin/make/unit-tests/varmod-subst.exp:1.7
--- src/usr.bin/make/unit-tests/varmod-subst.exp:1.6 Fri Jul 5 19:47:22 2024
+++ src/usr.bin/make/unit-tests/varmod-subst.exp Tue Jul 9 19:43:01 2024
@@ -59,4 +59,4 @@ mod-subst-dollar:$40:
mod-subst-dollar:U8:
mod-subst-dollar:$$$$:
mod-subst-dollar:$$$good3
-exit status 0
+exit status 2