mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-07-11 06:00:49 +02:00
commit bash-20070329 snapshot
This commit is contained in:
+52
-42
@@ -26,7 +26,7 @@
|
||||
|
||||
#if defined (qnx)
|
||||
# if defined (qnx6)
|
||||
# include <sy/netmgr.h>
|
||||
# include <sys/netmgr.h>
|
||||
# else
|
||||
# include <sys/vc.h>
|
||||
# endif /* !qnx6 */
|
||||
@@ -155,6 +155,8 @@ int array_needs_making = 1;
|
||||
int shell_level = 0;
|
||||
|
||||
/* Some forward declarations. */
|
||||
static void create_variable_tables __P((void));
|
||||
|
||||
static void set_machine_vars __P((void));
|
||||
static void set_home_var __P((void));
|
||||
static void set_shell_var __P((void));
|
||||
@@ -190,6 +192,8 @@ static SHELL_VAR *get_lineno __P((SHELL_VAR *));
|
||||
static SHELL_VAR *assign_subshell __P((SHELL_VAR *, char *, arrayind_t));
|
||||
static SHELL_VAR *get_subshell __P((SHELL_VAR *));
|
||||
|
||||
static SHELL_VAR *get_bashpid __P((SHELL_VAR *));
|
||||
|
||||
#if defined (HISTORY)
|
||||
static SHELL_VAR *get_histcmd __P((SHELL_VAR *));
|
||||
#endif
|
||||
@@ -252,19 +256,10 @@ static void push_func_var __P((PTR_T));
|
||||
static void push_exported_var __P((PTR_T));
|
||||
|
||||
static inline int find_special_var __P((const char *));
|
||||
|
||||
/* Initialize the shell variables from the current environment.
|
||||
If PRIVMODE is nonzero, don't import functions from ENV or
|
||||
parse $SHELLOPTS. */
|
||||
void
|
||||
initialize_shell_variables (env, privmode)
|
||||
char **env;
|
||||
int privmode;
|
||||
{
|
||||
char *name, *string, *temp_string;
|
||||
int c, char_index, string_index, string_length;
|
||||
SHELL_VAR *temp_var;
|
||||
|
||||
static void
|
||||
create_variable_tables ()
|
||||
{
|
||||
if (shell_variables == 0)
|
||||
{
|
||||
shell_variables = global_variables = new_var_context ((char *)NULL, 0);
|
||||
@@ -279,6 +274,21 @@ initialize_shell_variables (env, privmode)
|
||||
if (shell_function_defs == 0)
|
||||
shell_function_defs = hash_create (0);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Initialize the shell variables from the current environment.
|
||||
If PRIVMODE is nonzero, don't import functions from ENV or
|
||||
parse $SHELLOPTS. */
|
||||
void
|
||||
initialize_shell_variables (env, privmode)
|
||||
char **env;
|
||||
int privmode;
|
||||
{
|
||||
char *name, *string, *temp_string;
|
||||
int c, char_index, string_index, string_length;
|
||||
SHELL_VAR *temp_var;
|
||||
|
||||
create_variable_tables ();
|
||||
|
||||
for (string_index = 0; string = env[string_index++]; )
|
||||
{
|
||||
@@ -362,11 +372,7 @@ initialize_shell_variables (env, privmode)
|
||||
set_pwd ();
|
||||
|
||||
/* Set up initial value of $_ */
|
||||
#if 0
|
||||
temp_var = bind_variable ("_", dollar_vars[0], 0);
|
||||
#else
|
||||
temp_var = set_if_not ("_", dollar_vars[0]);
|
||||
#endif
|
||||
|
||||
/* Remember this pid. */
|
||||
dollar_dollar_pid = getpid ();
|
||||
@@ -509,6 +515,7 @@ initialize_shell_variables (env, privmode)
|
||||
{
|
||||
sv_history_control ("HISTCONTROL");
|
||||
sv_histignore ("HISTIGNORE");
|
||||
sv_histtimefmt ("HISTTIMEFORMAT");
|
||||
}
|
||||
#endif /* HISTORY */
|
||||
|
||||
@@ -1267,6 +1274,22 @@ get_subshell (var)
|
||||
return (var);
|
||||
}
|
||||
|
||||
static SHELL_VAR *
|
||||
get_bashpid (var)
|
||||
SHELL_VAR *var;
|
||||
{
|
||||
int pid;
|
||||
char *p;
|
||||
|
||||
pid = getpid ();
|
||||
p = itos (pid);
|
||||
|
||||
FREE (value_cell (var));
|
||||
VSETATTR (var, att_integer|att_readonly);
|
||||
var_setvalue (var, p);
|
||||
return (var);
|
||||
}
|
||||
|
||||
static SHELL_VAR *
|
||||
get_bash_command (var)
|
||||
SHELL_VAR *var;
|
||||
@@ -1306,20 +1329,11 @@ static SHELL_VAR *
|
||||
get_comp_wordbreaks (var)
|
||||
SHELL_VAR *var;
|
||||
{
|
||||
char *p;
|
||||
|
||||
/* If we don't have anything yet, assign a default value. */
|
||||
if (rl_completer_word_break_characters == 0 && bash_readline_initialized == 0)
|
||||
enable_hostname_completion (perform_hostname_completion);
|
||||
|
||||
#if 0
|
||||
FREE (value_cell (var));
|
||||
p = savestring (rl_completer_word_break_characters);
|
||||
|
||||
var_setvalue (var, p);
|
||||
#else
|
||||
var_setvalue (var, rl_completer_word_break_characters);
|
||||
#endif
|
||||
|
||||
return (var);
|
||||
}
|
||||
@@ -1457,6 +1471,9 @@ initialize_dynamic_variables ()
|
||||
INIT_DYNAMIC_VAR ("LINENO", (char *)NULL, get_lineno, assign_lineno);
|
||||
VSETATTR (v, att_integer);
|
||||
|
||||
INIT_DYNAMIC_VAR ("BASHPID", (char *)NULL, get_bashpid, null_assign);
|
||||
VSETATTR (v, att_integer|att_readonly);
|
||||
|
||||
#if defined (HISTORY)
|
||||
INIT_DYNAMIC_VAR ("HISTCMD", (char *)NULL, get_histcmd, (sh_var_assign_func_t *)NULL);
|
||||
VSETATTR (v, att_integer);
|
||||
@@ -1635,6 +1652,9 @@ set_if_not (name, value)
|
||||
{
|
||||
SHELL_VAR *v;
|
||||
|
||||
if (shell_variables == 0)
|
||||
create_variable_tables ();
|
||||
|
||||
v = find_variable (name);
|
||||
if (v == 0)
|
||||
v = bind_variable_internal (name, value, global_variables->table, HASH_NOSRCH, 0);
|
||||
@@ -1777,11 +1797,7 @@ make_new_variable (name, table)
|
||||
|
||||
/* Make sure we have a shell_variables hash table to add to. */
|
||||
if (shell_variables == 0)
|
||||
{
|
||||
shell_variables = global_variables = new_var_context ((char *)NULL, 0);
|
||||
shell_variables->scope = 0;
|
||||
shell_variables->table = hash_create (0);
|
||||
}
|
||||
create_variable_tables ();
|
||||
|
||||
elt = hash_insert (savestring (name), table, HASH_NOSRCH);
|
||||
elt->data = (PTR_T)entry;
|
||||
@@ -1949,11 +1965,7 @@ bind_variable (name, value, flags)
|
||||
VAR_CONTEXT *vc;
|
||||
|
||||
if (shell_variables == 0)
|
||||
{
|
||||
shell_variables = global_variables = new_var_context ((char *)NULL, 0);
|
||||
shell_variables->scope = 0;
|
||||
shell_variables->table = hash_create (0);
|
||||
}
|
||||
create_variable_tables ();
|
||||
|
||||
/* If we have a temporary environment, look there first for the variable,
|
||||
and, if found, modify the value there before modifying it in the
|
||||
@@ -2033,16 +2045,11 @@ bind_int_variable (lhs, rhs)
|
||||
char *lhs, *rhs;
|
||||
{
|
||||
register SHELL_VAR *v;
|
||||
char *t;
|
||||
int isint, isarr;
|
||||
|
||||
isint = isarr = 0;
|
||||
#if defined (ARRAY_VARS)
|
||||
# if 0
|
||||
if (t = xstrchr (lhs, '[')) /*]*/
|
||||
# else
|
||||
if (valid_array_reference (lhs))
|
||||
# endif
|
||||
{
|
||||
isarr = 1;
|
||||
v = array_variable_part (lhs, (char **)0, (int *)0);
|
||||
@@ -2991,7 +2998,10 @@ void
|
||||
dispose_used_env_vars ()
|
||||
{
|
||||
if (temporary_env)
|
||||
dispose_temporary_env (propagate_temp_var);
|
||||
{
|
||||
dispose_temporary_env (propagate_temp_var);
|
||||
maybe_make_export_env ();
|
||||
}
|
||||
}
|
||||
|
||||
/* Take all of the shell variables in the temporary environment HASH_TABLE
|
||||
|
||||
Reference in New Issue
Block a user