]> git.ipfire.org Git - thirdparty/bash.git/commitdiff
commit bash-20090702 snapshot
authorChet Ramey <chet.ramey@case.edu>
Fri, 9 Dec 2011 01:12:00 +0000 (20:12 -0500)
committerChet Ramey <chet.ramey@case.edu>
Fri, 9 Dec 2011 01:12:00 +0000 (20:12 -0500)
CWRU/CWRU.chlog
builtins/command.def
builtins/read.def
variables.c

index 4ed24ffb86bdcca4ee28a24e02473124c8e47f9c..9b75bc0f8e9ad632d1c30d6931c1a639e592a7cf 100644 (file)
@@ -8170,3 +8170,30 @@ lib/sh/getcwd.c
 configure.in
        - add -D_ALL_SOURCE to interix CFLAGS for struct timezone definition.
          Bug and fix from John Gatewood Ham <uraphalinuxserver@gmail.com>
+
+                                  6/29
+                                  ----
+variables.c
+       - change initialize_shell_variables to add environment variables with
+         invalid names to the variables hash table, but marking them as
+         invisible and imported
+       - new function, export_environment_candidate.  Used when creating the
+         export environment for commands to include variables with invalid
+         names inherited from the initial environment.  Apparently this
+         behavior is widespread
+       - change make_var_export_array to use export_environment_candidate
+         rather than visible_and_exported to test variables for inclusion
+         in the export environment
+
+                                   7/1
+                                   ---
+builtins/read.def
+       - fix a memory leak where the number of fields is not the same as
+         the number of variables passed to `read'.  Bug report from
+         werner@suse.de
+
+builtins/command.def
+       - move section of code that sets PATH from -p option before the
+         verbose-handling section, so command -v and command -V honor
+         the PATH set by command -p.  Bug and fix from
+         ohki@gssm.otsuka.tsukuba.ac.jp
index 77f91268bdc923592ccbd52d029a017c32efa649..18452799484c45d3f1b591b8221bae0b95ea09a5 100644 (file)
@@ -100,22 +100,6 @@ command_builtin (list)
   if (list == 0)
     return (EXECUTION_SUCCESS);
 
-  if (verbose)
-    {
-      int found, any_found;
-
-      for (any_found = 0; list; list = list->next)
-       {
-         found = describe_command (list->word->word, verbose);
-
-         if (found == 0 && verbose != CDESC_REUSABLE)
-           sh_notfound (list->word->word);
-
-         any_found += found;
-       }
-      return (any_found ? EXECUTION_SUCCESS : EXECUTION_FAILURE);
-    }
-
 #if defined (RESTRICTED_SHELL)
   if (use_standard_path && restricted)
     {
@@ -126,8 +110,6 @@ command_builtin (list)
 
   begin_unwind_frame ("command_builtin");
 
-  /* We don't want this to be reparsed (consider command echo 'foo &'), so
-     just make a simple_command structure and call execute_command with it. */
   if (use_standard_path)
     {      
       old_path = get_string_value ("PATH");
@@ -139,11 +121,32 @@ command_builtin (list)
 
       standard_path = get_standard_path ();
       bind_variable ("PATH", standard_path ? standard_path : "", 0);
+      stupidly_hack_special_variables ("PATH");
       FREE (standard_path);
     }
 
+  if (verbose)
+    {
+      int found, any_found;
+
+      for (any_found = 0; list; list = list->next)
+       {
+         found = describe_command (list->word->word, verbose);
+
+         if (found == 0 && verbose != CDESC_REUSABLE)
+           sh_notfound (list->word->word);
+
+         any_found += found;
+       }
+
+      run_unwind_frame ("command_builtin");
+      return (any_found ? EXECUTION_SUCCESS : EXECUTION_FAILURE);
+    }
+
 #define COMMAND_BUILTIN_FLAGS (CMD_NO_FUNCTIONS | CMD_INHIBIT_EXPANSION | CMD_COMMAND_BUILTIN)
 
+  /* We don't want this to be reparsed (consider command echo 'foo &'), so
+     just make a simple_command structure and call execute_command with it. */
   command = make_bare_simple_command ();
   command->value.Simple->words = (WORD_LIST *)copy_word_list (list);
   command->value.Simple->redirects = (REDIRECT *)NULL;
@@ -182,6 +185,8 @@ restore_path (var)
     }
   else
     unbind_variable ("PATH");
+
+  stupidly_hack_special_variables ("PATH");
 }
 
 /* Return a value for PATH that is guaranteed to find all of the standard
index ce486569dbe7a5b5c304335a02fe693d766acc72..75fd2371aa70cb030b8fd8771bf5cbf5ce46d4f3 100644 (file)
@@ -763,7 +763,10 @@ assign_vars:
       if (*input_string == 0)
        tofree = input_string = t;
       else
-       input_string = strip_trailing_ifs_whitespace (t1, ifs_chars, saw_escape);
+       {
+         input_string = strip_trailing_ifs_whitespace (t1, ifs_chars, saw_escape);
+         tofree = t;
+       }
     }
 #endif
 
index 263934b51641c07c2d84c5f2b2d7edcd78b458cc..e0179df105b095a90fa0af94275f77bd24e3edcc 100644 (file)
@@ -254,6 +254,7 @@ static SHELL_VAR **fapply __P((sh_var_map_func_t *));
 
 static int visible_var __P((SHELL_VAR *));
 static int visible_and_exported __P((SHELL_VAR *));
+static int export_environment_candidate __P((SHELL_VAR *));
 static int local_and_exported __P((SHELL_VAR *));
 static int variable_in_context __P((SHELL_VAR *));
 #if defined (ARRAY_VARS)
@@ -377,10 +378,17 @@ initialize_shell_variables (env, privmode)
        }
 #  endif
 #endif
+#if 0
       else if (legal_identifier (name))
+#else
+      else
+#endif
        {
          temp_var = bind_variable (name, string, 0);
-         VSETATTR (temp_var, (att_exported | att_imported));
+         if (legal_identifier (name))
+           VSETATTR (temp_var, (att_exported | att_imported));
+         else
+           VSETATTR (temp_var, (att_exported | att_imported | att_invisible));
          array_needs_making = 1;
        }
 
@@ -3089,6 +3097,16 @@ visible_and_exported (var)
   return (invisible_p (var) == 0 && exported_p (var));
 }
 
+/* Candidate variables for the export environment are either valid variables
+   with the export attribute or invalid variables inherited from the initial
+   environment and simply passed through. */
+static int
+export_environment_candidate (var)
+     SHELL_VAR *var;
+{
+  return (exported_p (var) && (invisible_p (var) == 0 || imported_p (var)));
+}
+
 /* Return non-zero if VAR is a local variable in the current context and
    is exported. */
 static int
@@ -3445,7 +3463,11 @@ make_var_export_array (vcxt)
   char **list;
   SHELL_VAR **vars;
 
+#if 0
   vars = map_over (visible_and_exported, vcxt);
+#else
+  vars = map_over (export_environment_candidate, vcxt);
+#endif
 
   if (vars == 0)
     return (char **)NULL;
@@ -3594,7 +3616,7 @@ maybe_make_export_env ()
        }
       export_env[export_env_index = 0] = (char *)NULL;
 
-      /* Make a dummy variable context from the  temporary_env, stick it on
+      /* Make a dummy variable context from the temporary_env, stick it on
         the front of shell_variables, call make_var_export_array on the
         whole thing to flatten it, and convert the list of SHELL_VAR *s
         to the form needed by the environment. */