make: do not expand variable name from the command line twice in a row
When 1. there is a global variable containing a dollar in its expanded name (very unlikely since there are lots of undocumented edge cases that make variable names containing dollar signs fragile), and 2. after that (unlikely since that requires .MAKEFLAGS instead of a normal command line) 3. there is a command line variable of the same name (again very unlikely since that variable name would contain a dollar sign as well in the expanded form), the global variable would not be undefined as promised by the comments since its name was expanded once more than intended. Because of the two 'very unlikely' above, this edge case hopefully does not affect any practical use cases. Note that this is not about VAR.${param} (which has a dollar sign in its unexpanded form), but about the case where param itself would expand to a dollar sign, such as after param=$$.
This commit is contained in:
parent
fbed66c0a8
commit
db1760d592
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: var.c,v 1.834 2021/02/22 21:43:57 rillig Exp $ */
|
||||
/* $NetBSD: var.c,v 1.835 2021/02/22 22:26:50 rillig Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
@ -140,7 +140,7 @@
|
||||
#include "metachar.h"
|
||||
|
||||
/* "@(#)var.c 8.3 (Berkeley) 3/19/94" */
|
||||
MAKE_RCSID("$NetBSD: var.c,v 1.834 2021/02/22 21:43:57 rillig Exp $");
|
||||
MAKE_RCSID("$NetBSD: var.c,v 1.835 2021/02/22 22:26:50 rillig Exp $");
|
||||
|
||||
typedef enum VarFlags {
|
||||
VFL_NONE = 0,
|
||||
@ -985,10 +985,9 @@ Var_SetWithFlags(GNode *scope, const char *name, const char *val,
|
||||
* added to SCOPE_GLOBAL, so delete it from there if
|
||||
* needed. Otherwise -V name may show the wrong value.
|
||||
*
|
||||
* See 'scope == SCOPE_GLOBAL' above.
|
||||
* See ExistsInCmdline.
|
||||
*/
|
||||
/* XXX: name is expanded for the second time */
|
||||
Var_DeleteExpand(SCOPE_GLOBAL, name);
|
||||
Var_Delete(SCOPE_GLOBAL, name);
|
||||
}
|
||||
v = VarAdd(name, val, scope, flags);
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user