Module Name:    src
Committed By:   sjg
Date:           Sat Dec  9 00:13:38 UTC 2023

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

Log Message:
make: Var_SetWithFlags set fromCmd for SCOPE_CMDLINE

Set fromCmd true for SCOPE_CMDLINE
regardless of the variable name.

Reviewed by: rillig


To generate a diff of this commit:
cvs rdiff -u -r1.1075 -r1.1076 src/usr.bin/make/var.c
cvs rdiff -u -r1.16 -r1.17 src/usr.bin/make/unit-tests/varname-dot-shell.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.1075 src/usr.bin/make/var.c:1.1076
--- src/usr.bin/make/var.c:1.1075	Sun Nov 19 22:50:11 2023
+++ src/usr.bin/make/var.c	Sat Dec  9 00:13:38 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.1075 2023/11/19 22:50:11 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.1076 2023/12/09 00:13:38 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.1075 2023/11/19 22:50:11 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.1076 2023/12/09 00:13:38 sjg Exp $");
 
 /*
  * Variables are defined using one of the VAR=value assignments.  Their
@@ -994,25 +994,26 @@ Var_SetWithFlags(GNode *scope, const cha
 	 * Any variables given on the command line are automatically exported
 	 * to the environment (as per POSIX standard), except for internals.
 	 */
-	if (scope == SCOPE_CMDLINE && !(flags & VAR_SET_NO_EXPORT) &&
-	    name[0] != '.') {
+	if (scope == SCOPE_CMDLINE) {
 		v->fromCmd = true;
+		if (!(flags & VAR_SET_NO_EXPORT) && name[0] != '.') {
 
-		/*
-		 * If requested, don't export these in the environment
-		 * individually.  We still put them in .MAKEOVERRIDES so
-		 * that the command-line settings continue to override
-		 * Makefile settings.
-		 */
-		if (!opts.varNoExportEnv)
-			setenv(name, val, 1);
-		/* XXX: What about .MAKE.EXPORTED? */
-		/*
-		 * XXX: Why not just mark the variable for needing export, as
-		 * in ExportVarPlain?
-		 */
-
-		Global_Append(".MAKEOVERRIDES", name);
+			/*
+			 * If requested, don't export these in the
+			 * environment individually.  We still put
+			 * them in .MAKEOVERRIDES so that the
+			 * command-line settings continue to override 
+			 * Makefile settings.
+			 */
+			if (!opts.varNoExportEnv)
+				setenv(name, val, 1);
+			/* XXX: What about .MAKE.EXPORTED? */
+			/*
+			 * XXX: Why not just mark the variable for
+			 * needing export, as in ExportVarPlain?
+			 */
+			Global_Append(".MAKEOVERRIDES", name);
+		}
 	}
 
 	if (name[0] == '.' && strcmp(name, MAKE_SAVE_DOLLARS) == 0)

Index: src/usr.bin/make/unit-tests/varname-dot-shell.exp
diff -u src/usr.bin/make/unit-tests/varname-dot-shell.exp:1.16 src/usr.bin/make/unit-tests/varname-dot-shell.exp:1.17
--- src/usr.bin/make/unit-tests/varname-dot-shell.exp:1.16	Sat Mar 26 14:34:07 2022
+++ src/usr.bin/make/unit-tests/varname-dot-shell.exp	Sat Dec  9 00:13:38 2023
@@ -5,7 +5,7 @@ Global: delete .SHELL (not found)
 Command: .SHELL = (details omitted)
 Global: ORIG_SHELL = (details omitted)
 Parsing line 12: .SHELL=		overwritten
-Global: .SHELL = overwritten
+Global: .SHELL = overwritten ignored!
 CondParser_Eval: ${.SHELL} != ${ORIG_SHELL}
 Var_Parse: ${.SHELL} != ${ORIG_SHELL} (eval-defined)
 Var_Parse: ${ORIG_SHELL} (eval-defined)
@@ -18,9 +18,9 @@ Var_Parse: ${.SHELL} != ${ORIG_SHELL} (e
 Var_Parse: ${ORIG_SHELL} (eval-defined)
 Comparing "(details omitted)" != "(details omitted)"
 Parsing line 27: .undef .SHELL
-Global: delete .SHELL
+Global: delete .SHELL (not found)
 Parsing line 28: .SHELL=		newly overwritten
-Global: .SHELL = newly overwritten
+Global: .SHELL = newly overwritten ignored!
 CondParser_Eval: ${.SHELL} != ${ORIG_SHELL}
 Var_Parse: ${.SHELL} != ${ORIG_SHELL} (eval-defined)
 Var_Parse: ${ORIG_SHELL} (eval-defined)

Reply via email to