From 90223a554ad261311cc16d92bac2a86fb51e70b8 Mon Sep 17 00:00:00 2001 From: Simon Schubert Date: Mon, 27 Jul 2009 11:43:58 +0200 Subject: [PATCH] make: expand .EXPORT/.makeenv variables We need to expand the value of a variable we want to put into the environment, otherwise they might appear as FOO=bar_${baz}. --- usr.bin/make/var.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/usr.bin/make/var.c b/usr.bin/make/var.c index b059f2219d..f408a99f62 100644 --- a/usr.bin/make/var.c +++ b/usr.bin/make/var.c @@ -1002,8 +1002,12 @@ Var_Set(const char name[], const char val[], GNode *ctxt) * are automatically exported to the * environment (as per POSIX standard) */ - if (setenv(n, val, 1) == -1) + char *exp_value; + + exp_value = Buf_Peel(Var_Subst(val, ctxt, false)); + if (setenv(n, exp_value, 1) == -1) Punt( "setenv: %s: can't allocate memory", n); + free(exp_value); } } @@ -1052,9 +1056,13 @@ Var_SetEnv(const char name[], GNode *ctxt) Error("Warning: .EXPORTVAR: set on undefined variable %s", name); } else { if ((v->flags & VAR_TO_ENV) == 0) { + char *value; + + value = Buf_Peel(Var_Subst(Buf_Data(v->val), ctxt, false)); v->flags |= VAR_TO_ENV; - if (setenv(v->name, Buf_Data(v->val), 1) == -1) + if (setenv(v->name, value, 1) == -1) Punt( "setenv: %s: can't allocate memory", v->name); + free(value); } } } -- 2.41.0