Skip to content

Commit 687bad5

Browse files
authored
docs: Update detail of global object creation
1 parent d8b198b commit 687bad5

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

docs/getting-started-technical.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,12 @@ Another implementation detail is how a new variable is created in the global sco
8989
local global_object_name=
9090
printf -v global_object_name '%q' "__bash_object_${root_object_name}_${root_object_query}_${RANDOM}_${RANDOM}"
9191

92-
if ! eval "declare -gA $global_object_name=()"; then
93-
bash_object.util.die 'ERROR_INTERNAL' 'Eval declare failed'
92+
if ! declare -gA "$global_object_name"; then
93+
bash_object.util.die 'ERROR_INTERNAL' "Could not declare variable '$global_object_name'"
9494
return
9595
fi
96+
local -n global_object="$global_object_name"
97+
global_object=()
9698
```
9799

98-
Unfortunately, it must use eval, but the `%q` should properly escape any escape sequences, since `root_object_name` and `root_object_query` are user-defined
100+
The `%q` probably isn't needed (it was originally there because the implementation previously used `eval`), but it's still there as of this writting

0 commit comments

Comments
 (0)