diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index c1d90167..2c19aef5 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -11262,3 +11262,11 @@ arrayfunc.c - valid_array_reference: make sure the array reference is properly terminated after the first subscript; return invalid if there is anything following the closing `]' + + 6/12 + ---- +variables.c + - bind_variable_internal: if asked to perform an array subscript + assignment on a nameref variable, display a warning and remove the + nameref attribute (as bash-4.3 did). Reported by Dan Douglas + diff --git a/bashline.c b/bashline.c index 552253b5..eb719443 100644 --- a/bashline.c +++ b/bashline.c @@ -981,9 +981,6 @@ edit_and_execute_command (count, c, editing_mode, edit_command) metaval = rl_variable_value ("input-meta"); metaflag = RL_BOOLEAN_VARIABLE_VALUE (metaval); - /* Now, POSIX.1-2001 and SUSv3 say that the commands executed from the - temporary file should be placed into the history. We don't do that - yet. */ if (rl_deprep_term_function) (*rl_deprep_term_function) (); save_parser_state (&ps); diff --git a/builtins/fc.def b/builtins/fc.def index 0c38a313..fe164710 100644 --- a/builtins/fc.def +++ b/builtins/fc.def @@ -447,6 +447,13 @@ fc_builtin (list) return (EXECUTION_FAILURE); } +#if defined (READLINE) + /* If we're executing as part of a dispatched readline commnand like + {emacs,vi}_edit_and_execute_command, the readline state will indicate it. + We could remove the partial command from the history, but ksh93 doesn't + so we stay compatible. */ +#endif + /* Make sure parse_and_execute doesn't turn this off, even though a call to parse_and_execute farther up the function call stack (e.g., if this is called by vi_edit_and_execute_command) may have already diff --git a/variables.c b/variables.c index 4d7bb46a..f249838c 100644 --- a/variables.c +++ b/variables.c @@ -2689,8 +2689,8 @@ bind_variable_internal (name, value, table, hflags, aflags) HASH_TABLE *table; int hflags, aflags; { - char *newval; - SHELL_VAR *entry; + char *newval, *tname; + SHELL_VAR *entry, *tentry; entry = (hflags & HASH_NOSRCH) ? (SHELL_VAR *)NULL : hash_lookup (name, table); /* Follow the nameref chain here if this is the global variables table */ @@ -2720,11 +2720,22 @@ bind_variable_internal (name, value, table, hflags, aflags) { newval = nameref_cell (entry); #if defined (ARRAY_VARS) - /* declare -n foo=x[2] */ + /* declare -n foo=x[2] ; foo=bar */ if (valid_array_reference (newval, 0)) { +tname = array_variable_name (newval, (char **)0, (int *)0); +if (tname && (tentry = find_variable_noref (tname)) && nameref_p (tentry)) + { + /* nameref variables can't be arrays */ + internal_warning (_("%s: removing nameref attribute"), name_cell (tentry)); +#if 1 + FREE (value_cell (tentry)); /* XXX - bash-4.3 compat */ + var_setvalue (tentry, (char *)NULL); +#endif + VUNSETATTR (tentry, att_nameref); + } /* XXX - should it be aflags? */ - entry = assign_array_element (newval, make_variable_value (entry, value, 0), aflags); + entry = assign_array_element (newval, make_variable_value (entry, value, 0), aflags|ASS_NAMEREF); if (entry == 0) return entry; }