commit bash-20160520 snapshot

This commit is contained in:
Chet Ramey
2016-05-23 09:57:30 -04:00
parent 0fcb334438
commit bddda3d2e1
32 changed files with 625 additions and 113 deletions
+6 -5
View File
@@ -344,7 +344,7 @@ declare_internal (list, local_var)
#if 1
if (value && *value && valid_nameref_value (value, 0) == 0)
{
builtin_error (_("%s: invalid variable name for name reference"), value);
builtin_error (_("`%s': invalid variable name for name reference"), value);
assign_error++;
NEXT_VARIABLE ();
}
@@ -570,7 +570,8 @@ declare_internal (list, local_var)
else
#endif
if (offset)
var = mkglobal ? bind_global_variable (name, "", 0) : bind_variable (name, "", 0);
/* We're just setting a temporary value here, so force assignment */
var = mkglobal ? bind_global_variable (name, (char *)NULL, ASS_FORCE) : bind_variable (name, (char *)NULL, ASS_FORCE);
else
{
var = mkglobal ? bind_global_variable (name, (char *)NULL, 0) : bind_variable (name, (char *)NULL, 0);
@@ -592,7 +593,7 @@ declare_internal (list, local_var)
}
else if (nameref_p (var) && (flags_on & att_nameref) == 0 && (flags_off & att_nameref) == 0 && offset && valid_nameref_value (value, 1) == 0)
{
builtin_error (_("%s: invalid variable name for name reference"), value);
builtin_error (_("`%s': invalid variable name for name reference"), value);
any_failed++;
NEXT_VARIABLE ();
}
@@ -601,9 +602,9 @@ declare_internal (list, local_var)
#if 1
/* Check of offset is to allow an assignment to a nameref var as
part of the declare word to override existing value */
if (nameref_p (var) == 0 && var_isset (var) && var_isnull (var) == 0 && offset == 0 && valid_nameref_value (value_cell (var), 0) == 0)
if (nameref_p (var) == 0 && var_isset (var) && offset == 0 && valid_nameref_value (value_cell (var), 0) == 0)
{
builtin_error (_("%s: invalid variable name for name reference"), value_cell (var));
builtin_error (_("`%s': invalid variable name for name reference"), value_cell (var));
any_failed++;
NEXT_VARIABLE ();
}
+3 -9
View File
@@ -106,16 +106,10 @@ getopts_unbind_variable (name)
char *name;
{
#if 0
SHELL_VAR *v;
v = find_variable (name);
if (v && readonly_p (v))
{
builtin_error (_("%s: cannot unset: readonly %s"), name, "variable");
return -1;
}
#endif
return (unbind_variable (name));
#else
return (unbind_variable_noref (name));
#endif
}
static int
+3 -2
View File
@@ -797,9 +797,10 @@ assign_vars:
}
else
var = bind_variable ("REPLY", input_string, 0);
VUNSETATTR (var, att_invisible);
if (readonly_p (var) || noassign_p (var))
if (var == 0 || readonly_p (var) || noassign_p (var))
retval = EXECUTION_FAILURE;
else
VUNSETATTR (var, att_invisible);
xfree (input_string);
return (retval);
+3 -3
View File
@@ -367,11 +367,11 @@ set_ignoreeof (on_or_off, option_name)
char *option_name;
{
ignoreeof = on_or_off == FLAG_ON;
unbind_variable ("ignoreeof");
unbind_variable_noref ("ignoreeof");
if (ignoreeof)
bind_variable ("IGNOREEOF", "10", 0);
else
unbind_variable ("IGNOREEOF");
unbind_variable_noref ("IGNOREEOF");
sv_ignoreeof ("IGNOREEOF");
return 0;
}
@@ -383,7 +383,7 @@ set_posix_mode (on_or_off, option_name)
{
posixly_correct = on_or_off == FLAG_ON;
if (posixly_correct == 0)
unbind_variable ("POSIXLY_CORRECT");
unbind_variable_noref ("POSIXLY_CORRECT");
else
bind_variable ("POSIXLY_CORRECT", "y", 0);
sv_strict_posix ("POSIXLY_CORRECT");
+20 -3
View File
@@ -538,8 +538,8 @@ set_var_attribute (name, attribute, undo)
char *name;
int attribute, undo;
{
SHELL_VAR *var, *tv, *v;
char *tvalue;
SHELL_VAR *var, *tv, *v, *refvar;
char *tvalue, *refname;
if (undo)
var = find_variable (name);
@@ -554,6 +554,11 @@ set_var_attribute (name, attribute, undo)
tvalue = var_isset (tv) ? savestring (value_cell (tv)) : savestring ("");
var = bind_variable (tv->name, tvalue, 0);
if (var == 0)
{
free (tvalue);
return; /* XXX - no error message here */
}
var->attributes |= tv->attributes & ~att_tempvar;
/* This avoids an error message when propagating a read-only var
later on. */
@@ -578,10 +583,22 @@ set_var_attribute (name, attribute, undo)
else
{
var = find_variable_notempenv (name);
if (var == 0)
{
/* We might have a nameref pointing to something that we can't
resolve to a shell variable. If we do, skip it. We do a little
checking just so we can print an error message. */
refvar = find_variable_nameref_for_create (name, 0);
if (refvar == INVALID_NAMEREF_VALUE)
return;
/* Otherwise we probably have a nameref pointing to a variable
that hasn't been created yet. bind_variable will take care
of that. */
}
if (var == 0)
{
var = bind_variable (name, (char *)NULL, 0);
if (no_invisible_vars == 0)
if (var && no_invisible_vars == 0)
VSETATTR (var, att_invisible);
}
else if (var->context != 0)