diff --git a/osh/word_eval.py b/osh/word_eval.py index 87cf09bc7a..68f82b9412 100644 --- a/osh/word_eval.py +++ b/osh/word_eval.py @@ -997,7 +997,7 @@ def _EvalBracedVarSub(self, part, part_vals, quoted): # avoid it. rhs_str = _DecayPartValuesToString(effect_part_vals, self.splitter.GetJoinChar()) - state.SetLocalString(self.mem, var_name, rhs_str) + state.SetStringDynamic(self.mem, var_name, rhs_str) return # EARLY RETURN, part_vals mutated elif effect == effect_e.Error: diff --git a/spec/var-op-test.test.sh b/spec/var-op-test.test.sh index e5bb8c9a10..d2ac4e4076 100644 --- a/spec/var-op-test.test.sh +++ b/spec/var-op-test.test.sh @@ -106,3 +106,17 @@ echo should not get here v=foo echo ${v+v is not unset} ${unset:+is not unset} ## stdout: v is not unset + +#### ${var=x} dynamic scope +f() { : "${hello:=x}"; echo $hello; } +f +echo hello=$hello + +f() { hello=x; } +f +echo hello=$hello +## STDOUT: +x +hello=x +hello=x +## END