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
This commit is contained in:
osm0sis committed 2017-05-04 18:02:00 -03:00
1 parent a4adf0111e
commit fd5bfaa381
1 file changed
+10
+10
View File
@@ -302,5 +302,15 @@ patch_cmdline() {
fi;
}
# patch_prop <prop file> <prop name> <new prop value>
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