]> git.plutz.net Git - cgilite/commitdiff
bugfix: prevent content duplication when deleting nonexist key master
authorPaul Hänsch <paul@plutz.net>
Mon, 26 May 2025 19:30:20 +0000 (21:30 +0200)
committerPaul Hänsch <paul@plutz.net>
Mon, 26 May 2025 19:30:20 +0000 (21:30 +0200)
db23.sh

diff --git a/db23.sh b/db23.sh
index 8ee6f4fe528ab3e96b9c2cc4bc41fe697220b099..b7ab5485c32b1f0f4a5141303b8b875124e54d77 100755 (executable)
--- 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