From f3e62324e9e55df1cca5b002d8264bf5dd56d0d0 Mon Sep 17 00:00:00 2001 From: AuxXxilium Date: Wed, 20 Nov 2024 11:35:16 +0100 Subject: [PATCH] config: update Signed-off-by: AuxXxilium --- config-manipulators.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/config-manipulators.sh b/config-manipulators.sh index 1bb5024..8d7c7a1 100755 --- a/config-manipulators.sh +++ b/config-manipulators.sh @@ -13,7 +13,7 @@ fi ##$1 from, $2 to, $3 file to path _replace_in_file() { if grep -q "${1}" "${3}"; then - "${SED_PATH}" -i "${3}" -e "s#${1}#${2}#" + "${SED_PATH}" -i "s#${1}#${2}#" "${3}" 2>/dev/null fi } @@ -22,17 +22,18 @@ _replace_in_file() { # Args: $1 name, $2 new_val, $3 path _set_conf_kv() { # Delete - if [ -z "$2" ]; then - "${SED_PATH}" -i "${3}" -e "s/^${1}=.*$//" + if [ -z "${2}" ]; then + "${SED_PATH}" -i "/^${1}=/d" "${3}" 2>/dev/null return 0 fi # Replace if grep -q "^${1}=" "${3}"; then - "${SED_PATH}" -i "${3}" -e "s\"^${1}=.*\"${1}=\\\"${2}\\\"\"" + "${SED_PATH}" -i "s#^${1}=.*#${1}=\"${2}\"#" "${3}" 2>/dev/null return 0 fi # Add if doesn't exist echo "${1}=\"${2}\"" >>"${3}" -} + return 0 +} \ No newline at end of file