Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make make(1): ignore -env and -literal in assignment...
details: https://anonhg.NetBSD.org/src/rev/5f86b2c8eae7
branches: trunk
changeset: 940074:5f86b2c8eae7
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Oct 03 10:42:08 2020 +0000
description:
make(1): ignore -env and -literal in assignments to .MAKE.EXPORTED
Previously, assigning the string "-env" to the variable .MAKE.EXPORTED
had the same effect as the .export-env directive. This was only due to
a sloppy implementation, not by design.
For the string "-literal" and the directive .export-literal, the
situation was even worse since the actually executed code was a wild
mixture between .export and .export-literal that in the end exported the
expanded form of the variable. Therefore there was no practical use
case of this implementation flaw.
diffstat:
usr.bin/make/unit-tests/make-exported.mk | 26 ++++++++++----------------
usr.bin/make/var.c | 8 ++++----
2 files changed, 14 insertions(+), 20 deletions(-)
diffs (73 lines):
diff -r 011b717f478f -r 5f86b2c8eae7 usr.bin/make/unit-tests/make-exported.mk
--- a/usr.bin/make/unit-tests/make-exported.mk Sat Oct 03 10:31:05 2020 +0000
+++ b/usr.bin/make/unit-tests/make-exported.mk Sat Oct 03 10:42:08 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: make-exported.mk,v 1.3 2020/10/03 10:31:05 rillig Exp $
+# $NetBSD: make-exported.mk,v 1.4 2020/10/03 10:42:09 rillig Exp $
#
# As of 2020-08-09, the code in Var_Export is shared between the .export
# directive and the .MAKE.EXPORTED variable. This leads to non-obvious
@@ -8,23 +8,17 @@
-literal= make-exported-value-literal
UT_VAR= ${UNEXPANDED}
-# The following behavior is probably not intended.
-.MAKE.EXPORTED= -env # behaves like .export-env
+# Before 2020-10-03, the following line took the code path of .export-env,
+# which was surprising behavior. Since 2020-10-03 this line tries to
+# export the variable named "-env", but that is rejected because the
+# variable name starts with a hyphen.
+.MAKE.EXPORTED= -env
-# If the value of .MAKE.EXPORTED starts with "-literal", make behaves like
-# a mixture of .export-literal and a regular .export.
-# XXX: This is due to a sloppy implementation, reusing code in places where
-# it is not appropriate.
+# Before 2020-10-03, if the value of .MAKE.EXPORTED started with "-literal",
+# make behaved like a mixture of .export-literal and a regular .export.
#
-# In Parse_DoVar, the code path for MAKE_EXPORTED is taken, calling Var_Export
-# in turn. There, the code path for .export-literal is taken, and the
-# environment variable UT_VAR is set to ${UNEXPANDED}, as expected.
-# Later, in Compat_RunCommand, in the child process after vfork,
-# Var_ExportVars is called, which treats "-literal" as an ordinary variable
-# name, therefore exports it and also overwrites the previously exported
-# UT_VAR with the expanded value.
-#
-# Since 2020-10-03, the "variable" named "-literal" is not exported anymore.
+# Since 2020-10-03, the "variable" named "-literal" is not exported anymore,
+# it is just ignored since its name starts with '-'.
.MAKE.EXPORTED= -literal UT_VAR
all:
diff -r 011b717f478f -r 5f86b2c8eae7 usr.bin/make/var.c
--- a/usr.bin/make/var.c Sat Oct 03 10:31:05 2020 +0000
+++ b/usr.bin/make/var.c Sat Oct 03 10:42:08 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.558 2020/10/03 10:31:05 rillig Exp $ */
+/* $NetBSD: var.c,v 1.559 2020/10/03 10:42:08 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -121,7 +121,7 @@
#include "metachar.h"
/* "@(#)var.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.558 2020/10/03 10:31:05 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.559 2020/10/03 10:42:08 rillig Exp $");
#define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
#define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -603,10 +603,10 @@
return;
}
- if (strncmp(str, "-env", 4) == 0) {
+ if (isExport && strncmp(str, "-env", 4) == 0) {
str += 4;
flags = 0;
- } else if (strncmp(str, "-literal", 8) == 0) {
+ } else if (isExport && strncmp(str, "-literal", 8) == 0) {
str += 8;
flags = VAR_EXPORT_LITERAL;
} else {
Home |
Main Index |
Thread Index |
Old Index