diff options
| author | sjg <sjg@NetBSD.org> | 2013-07-16 20:00:56 +0000 |
|---|---|---|
| committer | sjg <sjg@NetBSD.org> | 2013-07-16 20:00:56 +0000 |
| commit | 20b8b07eb5191fbf81fa7b5ca2d46561bc92ad10 (patch) | |
| tree | a2d73acd08c85e0717c030fe4403f5be95aa1ee4 /usr.bin/make | |
| parent | 4a7c42ea613993576faffe12c831203a6bd05c4b (diff) | |
When a var is set in the CMD context, it prevents the same name
being set in GLOBAL context. We should also delete any such
variable in GLOBAL context, else make -V will show the wrong value.
Diffstat (limited to 'usr.bin/make')
| -rw-r--r-- | usr.bin/make/var.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/usr.bin/make/var.c b/usr.bin/make/var.c index a6721ea1a9c..c5c16b8803b 100644 --- a/usr.bin/make/var.c +++ b/usr.bin/make/var.c @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.182 2013/07/16 14:00:53 christos Exp $ */ +/* $NetBSD: var.c,v 1.183 2013/07/16 20:00:56 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: var.c,v 1.182 2013/07/16 14:00:53 christos Exp $"; +static char rcsid[] = "$NetBSD: var.c,v 1.183 2013/07/16 20:00:56 sjg Exp $"; #else #include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: var.c,v 1.182 2013/07/16 14:00:53 christos Exp $"); +__RCSID("$NetBSD: var.c,v 1.183 2013/07/16 20:00:56 sjg Exp $"); #endif #endif /* not lint */ #endif @@ -929,6 +929,14 @@ Var_Set(const char *name, const char *val, GNode *ctxt, int flags) } v = VarFind(name, ctxt, 0); if (v == NULL) { + if (ctxt == VAR_CMD && (flags & VAR_NO_EXPORT) == 0) { + /* + * This var would normally prevent the same name being added + * to VAR_GLOBAL, so delete it from there if needed. + * Otherwise -V name may show the wrong value. + */ + Var_Delete(name, VAR_GLOBAL); + } VarAdd(name, val, ctxt); } else { Buf_Empty(&v->val); |
