[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

nameref in temp environment

From: Grisha Levit
Subject: nameref in temp environment
Date: Thu, 12 May 2016 20:58:49 -0400

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.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]