X-Git-Url: https://git.plutz.net/?a=blobdiff_plain;f=storage.sh;h=5c61df0a041e75df0e1ee0e81aa0c09078cdabc1;hb=refs%2Fheads%2Fmaster;hp=17ea0d051eaf27233f8b5cd96f7396974c7a87f1;hpb=ad6888a95e36f5ad2be6555d20c9216bcd3d1aa7;p=cgilite diff --git a/storage.sh b/storage.sh index 17ea0d0..5c61df0 100755 --- a/storage.sh +++ b/storage.sh @@ -94,6 +94,21 @@ UNSTRING(){ printf '%s\n' "$out" } +RXLITERAL(){ + # sed -E 's;[].*+?^${}()|\[];\\&;g' + local in out='' + [ $# -gt 0 ] && in="$*" || in="$(cat)" + while [ "$in" ]; do case $in in + [.+^\$\{\}\(\)\[\]\*\?\|\\]*) + out="${out}\\${in%"${in#?}"}"; in="${in#?}"; + ;; + *)out="${out}${in%%[.+^\$\{\}\(\)\[\]\*\?\|\\]*}" + in="${in#"${in%%[.+^\$\{\}\(\)\[\]\*\?\|\\]*}"}" + ;; + esac; done + printf '%s\n' "$out" +} + DBM() { local file="$1" cmd="$2" local k v key value