summaryrefslogtreecommitdiff
path: root/variables.c
diff options
context:
space:
mode:
Diffstat (limited to 'variables.c')
-rw-r--r--variables.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/variables.c b/variables.c
index e1a4d789..e5d09892 100644
--- a/variables.c
+++ b/variables.c
@@ -357,6 +357,7 @@ initialize_shell_variables (env, privmode)
temp_var = (SHELL_VAR *)NULL;
+#if defined (FUNCTION_IMPORT)
/* If exported function, define it now. Don't import functions from
the environment in privileged mode. */
if (privmode == 0 && read_but_dont_execute == 0 &&
@@ -406,6 +407,7 @@ initialize_shell_variables (env, privmode)
/* Restore original suffix */
tname[namelen] = BASHFUNC_SUFFIX[0];
}
+#endif /* FUNCTION_IMPORT */
#if defined (ARRAY_VARS)
# if ARRAY_EXPORT
/* Array variables may not yet be exported. */
@@ -420,11 +422,7 @@ initialize_shell_variables (env, privmode)
}
# endif /* ARRAY_EXPORT */
#endif
-#if 0
- else if (legal_identifier (name))
-#else
else
-#endif
{
ro = 0;
if (posixly_correct && STREQ (name, "SHELLOPTS"))
@@ -5158,10 +5156,16 @@ void
sv_optind (name)
char *name;
{
+ SHELL_VAR *var;
char *tt;
int s;
- tt = get_string_value ("OPTIND");
+ var = find_variable ("OPTIND");
+ tt = var ? get_variable_value (var) : (char *)NULL;
+
+ /* Assume that if var->context < variable_context and variable_context > 0
+ then we are restoring the variables's previous state while returning
+ from a function. */
if (tt && *tt)
{
s = atoi (tt);