Compare commits

..

No commits in common. "4df7be9a7cbc932fbb5e0c5b56379d01a2cdb398" and "44c2aec5ca7574fa1fa84a813d9944ff779e55aa" have entirely different histories.

2 changed files with 14 additions and 7 deletions

View file

@ -51,7 +51,7 @@ function html_encode() {
# url_encode(string)
function url_encode() {
echo -n "$1" | xxd -p | tr -d '\n' | sed 's/../%&/g'
echo -n "$1" | xxd -p | tr -d '\n' | sed -E 's/.{2}/%&/g'
}
# url_decode(string)

View file

@ -133,6 +133,12 @@ _template_gen_special_uri() {
echo "s${_tpl_ctrl}\{\{-uri\}\}${_tpl_ctrl}${r[url_clean]}${_tpl_ctrl}g;"
}
# mmmm this should be a library because i am so much copying those later
# _nested_random
function _nested_random() {
dd if=/dev/urandom bs=1 count=16 status=none | xxd -p
}
# nested_declare(ref)
function nested_declare() {
declare -g -a $1
@ -140,14 +146,15 @@ function nested_declare() {
# nested_add(ref, array)
function nested_add() {
local nested_id=template_internal_$EPOCHSECONDS$RANDOM$RANDOM$RANDOM$RANDOM$RANDOM$RANDOM
local nested_id=$(_nested_random)
declare -g -A _$nested_id
local a
a="$(declare -p "$2")"
# pain
eval "${a/ $2=/ -g _$nested_id=}"
local -n ref=$1
local -n arr_ref=$2
local IFS=
: "${arr_ref[@]@A}"
declare -g -${arr_ref@a} _$nested_id="${_#*=}"
ref+=("$nested_id")
}