From fd5bfaa381ababd495e9ea27204c89e66c61bc23 Mon Sep 17 00:00:00 2001 From: osm0sis Date: Thu, 4 May 2017 18:02:00 -0300 Subject: [PATCH] AK2: introduce .prop files patching function patch_prop: - if matched name is not present, appends new prop entry to the end of the file - if matched name is present, replaces the entry with the new value --- tools/ak2-core.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tools/ak2-core.sh b/tools/ak2-core.sh index 0b7de80..8a03e17 100755 --- a/tools/ak2-core.sh +++ b/tools/ak2-core.sh @@ -302,5 +302,15 @@ patch_cmdline() { fi; } +# patch_prop +patch_prop() { + if [ -z "$(grep "^$2=" $1)" ]; then + echo -ne "\n$2=$3\n" >> $1; + else + line=`grep -n "^$2=" $1 | head -n1 | cut -d: -f1`; + sed -i "${line}s;.*;${2}=${3};" $1; + fi; +} + ## end methods