summaryrefslogtreecommitdiff
path: root/bos-namespaces.sh
diff options
context:
space:
mode:
Diffstat (limited to 'bos-namespaces.sh')
-rw-r--r--bos-namespaces.sh22
1 files changed, 18 insertions, 4 deletions
diff --git a/bos-namespaces.sh b/bos-namespaces.sh
index 3e9e711..9fbbb08 100644
--- a/bos-namespaces.sh
+++ b/bos-namespaces.sh
@@ -1,9 +1,23 @@
#!bash
## namespace handling
-function bos-namespaces/store-for-into() {
+function bos-namespaces/store-scalar-for-into() {
local name="bos_namespaces__${2//[^[:word:]/__}__${1//[^[:word:]]/__}"
- local -n result="$2"
+ local -n result="$3"
+ declare -g "$name"
+ result="$name"
+}
+
+function bos-namespaces/store-array-for-into() {
+ local name="bos_namespaces__${2//[^[:word:]/__}__${1//[^[:word:]]/__}"
+ local -n result="$3"
+ declare -ga "$name"
+ result="$name"
+}
+
+function bos-namespaces/store-dict-for-into() {
+ local name="bos_namespaces__${2//[^[:word:]/__}__${1//[^[:word:]]/__}"
+ local -n result="$3"
declare -gA "$name"
result="$name"
}
@@ -11,7 +25,7 @@ function bos-namespaces/store-for-into() {
# save all currently-visible functions in an associative array
function bos-namespaces/start() {
local namespace="$1";shift
- local ns_store; bos-namespaces/store-for-into saved_funcs "$namespace" ns_store
+ local ns_store; bos-namespaces/store-dict-for-into saved_funcs "$namespace" ns_store
local -n saved_funcs="$ns_store"
local _ funcname
@@ -27,7 +41,7 @@ function bos-namespaces/start() {
function bos-namespaces/list-new-funcs-into() {
local namespace="$1";shift
local -n result="$1"
- local ns_store; bos-namespaces/store-for-into saved_funcs "$namespace" ns_store
+ local ns_store; bos-namespaces/store-dict-for-into saved_funcs "$namespace" ns_store
local -n saved_funcs="$ns_store"
local _ funcname new_function