From: Paul Hänsch Date: Mon, 26 May 2025 19:30:20 +0000 (+0200) Subject: bugfix: prevent content duplication when deleting nonexist key X-Git-Url: https://git.plutz.net/?p=cgilite;a=commitdiff_plain;h=HEAD;ds=sidebyside bugfix: prevent content duplication when deleting nonexist key --- diff --git a/db23.sh b/db23.sh index 8ee6f4f..b7ab548 100755 --- a/db23.sh +++ b/db23.sh @@ -65,8 +65,12 @@ DB2() { delete|remove) key="$(STRING "$1")" val="${data#*"${BR}${key}" *"${BR}"}" key="${data%"${BR}${key}" *"${BR}"*}" - [ "${key}${BR}${val}" = "${data}" ] && return 1 - printf '%s' "${key#"${BR}"}${BR}${val%"${BR}"}" + if [ "${val}" = "${data}" ]; then + printf %s\\n "${data}" + return 1 + else + printf '%s' "${key#"${BR}"}${BR}${val%"${BR}"}" + fi ;; set|store) key="$(STRING "$1")" val="" shift 1