Fix bug with SHELL handling: make sure the variable struct is initialized.
authorPaul Smith <psmith@gnu.org>
Sun, 5 Dec 2004 18:09:31 +0000 (18:09 +0000)
committerPaul Smith <psmith@gnu.org>
Sun, 5 Dec 2004 18:09:31 +0000 (18:09 +0000)
ChangeLog
main.c
make.h
variable.c

index a30f9892469c59042e2db02a873bf4e56d2861a0..fe318e7cad8ef4a9f695f7697efed5b97d60bfc0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2004-12-01  Paul D. Smith  <psmith@gnu.org>
+
+       * main.c (main): Change char* env_shell to struct variable shell_var.
+       * variable.c (target_environment): Use new shell_var.
+
 2004-11-30  Paul D. Smith  <psmith@gnu.org>
 
        * configure.in: The old way we avoided creating build.sh from
diff --git a/main.c b/main.c
index 763fd5468787d699e0b80236e396688fe64c1deb..10869085730332902150e835ae3e9f30e37d48ed 100644 (file)
--- a/main.c
+++ b/main.c
@@ -266,7 +266,7 @@ int rebuilding_makefiles = 0;
 
 /* Remember the original value of the SHELL variable, from the environment.  */
 
-const char *env_shell = 0;
+struct variable shell_var;
 
 \f
 /* The usage output.  We write it this way to make life easier for the
@@ -1084,7 +1084,8 @@ main (int argc, char **argv, char **envp)
           if (strncmp (envp[i], "SHELL=", 6) == 0)
             {
               v->export = v_noexport;
-              env_shell = xstrdup (ep + 1);
+              shell_var.name = "SHELL";
+              shell_var.value = xstrdup (ep + 1);
             }
         }
     }
diff --git a/make.h b/make.h
index 55dcc215cd1ea55c4fdaa8107516fc12f50e819f..ad46e1f8a7cf6756c46f479eac9bfeab90974a19 100644 (file)
--- a/make.h
+++ b/make.h
@@ -496,8 +496,6 @@ extern int print_version_flag, print_directory_flag;
 extern int warn_undefined_variables_flag, posix_pedantic, not_parallel;
 extern int clock_skew_detected, rebuilding_makefiles;
 
-extern const char *env_shell;
-
 /* can we run commands via 'sh -c xxx' or must we use batch files? */
 extern int batch_mode_shell;
 
index 8398d18bb133bad2abd400358ea3208a5f9b6a94..495aef45ae37abbc0bc5aeeac9bb9297029017a8 100644 (file)
@@ -807,11 +807,6 @@ 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;
@@ -868,12 +863,15 @@ target_environment (struct file *file)
                break;
 
              case v_noexport:
-                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;
+                if (streq (v->name, "SHELL"))
+                  {
+                    extern struct variable shell_var;
+                    v = &shell_var;
+                    break;
+                  }
+                continue;
 
              case v_ifset:
                if (v->origin == o_default)