From 539f513773b2e651d987a7bdbdffd8b5164d58cf Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Sun, 28 Nov 2004 23:11:23 +0000 Subject: Fix for bug #1276: Handle SHELL according to POSIX requirements. POSIX requires that the value of SHELL in the makefile NOT be exported to sub-commands. Instead, the value in the environment when make was invoked should be passed to the environment of sub-commands. Note that make still uses SHELL to _run_ sub-commands; it just doesn't change the value of the SHELL variable in the environment of sub-commands. As an extension to POSIX, if the makefile explicitly exports SHELL then GNU make _will_ use it in the environment of sub-commands. --- variable.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'variable.c') diff --git a/variable.c b/variable.c index 31b84a4..8398d18 100644 --- a/variable.c +++ b/variable.c @@ -739,16 +739,14 @@ define_automatic_variables (void) #endif - /* This won't override any definition, but it - will provide one if there isn't one there. */ + /* This won't override any definition, but it will provide one if there + isn't one there. */ v = define_variable ("SHELL", 5, default_shell, o_default, 0); - v->export = v_export; /* Always export SHELL. */ - /* On MSDOS we do use SHELL from environment, since - it isn't a standard environment variable on MSDOS, - so whoever sets it, does that on purpose. - On OS/2 we do not use SHELL from environment but - we have already handled that problem above. */ + /* On MSDOS we do use SHELL from environment, since it isn't a standard + environment variable on MSDOS, so whoever sets it, does that on purpose. + On OS/2 we do not use SHELL from environment but we have already handled + that problem above. */ #if !defined(__MSDOS__) && !defined(__EMX__) /* Don't let SHELL come from the environment. */ if (*v->value == '\0' || v->origin == o_env || v->origin == o_env_override) @@ -809,6 +807,11 @@ target_environment (struct file *file) struct variable makelevel_key; char **result_0; char **result; + struct variable ev; + + /* Set up a fake variable struct for the original SHELL value. */ + ev.name = "SHELL"; + ev.value = env_shell; if (file == 0) set_list = current_variable_set_list; @@ -865,7 +868,12 @@ target_environment (struct file *file) break; case v_noexport: - continue; + if (!streq (v->name, "SHELL")) + continue; + /* If this is the SHELL variable and it's not exported, then + add the value from our original environment. */ + v = &ev; + break; case v_ifset: if (v->origin == o_default) -- cgit v1.2.3