From 10da8553c70f39fef0af34c2b812556361eda72a Mon Sep 17 00:00:00 2001 From: CyberLeo Date: Sun, 3 Mar 2013 10:48:01 -0600 Subject: [PATCH] kvs: add has_key implementation --- lib/kvs.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/kvs.sh b/lib/kvs.sh index 0c2059d..2a08225 100644 --- a/lib/kvs.sh +++ b/lib/kvs.sh @@ -40,6 +40,14 @@ kvs_has_id() { grep -q "^${id}${t}" "${kvs}" } +# Does the kvs have a given key for a given ID? +kvs_has_key() { + [ "${1}" -a "${2}" ] || return 255 + local id="${1}" + local var="${2}" + grep -q "^${id}${t}${var}${t}" "${kvs}" +} + # Remove a given key with a given ID from the kvs kvs_unset() { [ "${1}" -a "${2}" ] || return 255 -- 2.45.0