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
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)
{
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");
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;
}
else
unbind_variable ("PATH");
+
+ stupidly_hack_special_variables ("PATH");
}
/* Return a value for PATH that is guaranteed to find all of the standard
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
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)
}
# 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;
}
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
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;
}
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. */