hi, there are two issues here, small regressions. I think in tmpenv we should create the variable unconditionally (concerning the namerefs), and should not follow the namerefs on checking if the variable exists:
diff --git a/variables.c b/variables.c index 1877b17..f149b66 100644 --- a/variables.c +++ b/variables.c @@ -3076,7 +3076,7 @@ assign_in_env (word, flags) aflags |= ASS_APPEND; } - var = find_variable (name); + var = find_variable_noref(name); if (var == 0) var = find_variable_last_nameref (name, 1); @@ -3088,14 +3088,6 @@ assign_in_env (word, flags) return (0); } temp = name + offset + 1; - if (var && nameref_p (var) && valid_nameref_value (temp, 0) == 0) - { - /* If we're assigning a value to a nameref variable in the temp - environment that's an invalid name, flag an error. */ - sh_invalidid (temp); - free (name); - return (0); - } value = expand_assignment_string_to_string (temp, 0); cheers, pg On 13 May 2016, at 02:58, Grisha Levit wrote: > The 20160506 snapshot changes assign_in_env to do some nameref-related checks > on the variable name, but these don’t really seem to make sense since > assignments in the temporary env just create regular variables and don’t > follow the nameref chain otherwise. > > i.e. bash doesn’t actually care that ref is a nameref at the outer scope for > the purposes of creating the temp env: > > $ unset var; declare -n ref=var > $ ref=xxx declare -p ref var # the chain is not followed for assignment > (makes sense) > declare -x ref="xxx" > bash: declare: var: not found > > $ var= ref=5 declare -p ref > declare -x ref="5" > > $ ref=5 declare -p ref > bash: `5': not a valid identifier # this shouldn't matter? > declare -n ref="var" > > Same thing for the check to see if ref points to a readonly variable. >