aboutsummaryrefslogtreecommitdiff
path: root/bash/printer.sh
diff options
context:
space:
mode:
Diffstat (limited to 'bash/printer.sh')
-rw-r--r--bash/printer.sh26
1 files changed, 20 insertions, 6 deletions
diff --git a/bash/printer.sh b/bash/printer.sh
index 911db17..0d23028 100644
--- a/bash/printer.sh
+++ b/bash/printer.sh
@@ -29,28 +29,42 @@ symbol_pr_str () {
r="${r//__STAR__/*}"
}
-string_pr_str () {
+keyword_pr_str () {
+ string_pr_str "${1}"
+}
+
+_raw_string_pr_str () {
+ local s="${1}"
local print_readably="${2}"
- if [ "${print_readably}" == "yes" ]; then
- local s="${ANON["${1}"]}"
+ if [[ "${s:0:1}" = "${__keyw}" ]]; then
+ r=":${s:1}"
+ elif [ "${print_readably}" == "yes" ]; then
s="${s//\\/\\\\}"
r="\"${s//\"/\\\"}\""
else
- r="${ANON["${1}"]}"
+ r="${s}"
fi
r="${r//__STAR__/$'*'}"
}
+string_pr_str () {
+ _raw_string_pr_str "${ANON["${1}"]}" "${2}"
+}
+
function_pr_str () { r="${ANON["${1}"]}"; }
+bash_pr_str () {
+ r="$(declare -f -p ${1})"
+}
+
hash_map_pr_str () {
local print_readably="${2}"
local res=""; local val=""
local hm="${ANON["${1}"]}"
eval local keys="\${!${hm}[@]}"
for key in ${keys}; do
- #res="${res} \"${ANON["${key}"]}\""
- res="${res} \"${key//__STAR__/$'*'}\""
+ _raw_string_pr_str "${key}" "${print_readably}"
+ res="${res} ${r}"
eval val="\${${hm}[\"${key}\"]}"
_pr_str "${val}" "${print_readably}"
res="${res} ${r}"