From 0c39114d102cb1d523b2b7b63f7d9caba4cf441c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Mon, 26 May 2025 21:30:20 +0200 Subject: [PATCH] bugfix: prevent content duplication when deleting nonexist key --- db23.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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 -- 2.39.5