AK2: allow next blank line (" ") for replace_section and remove_section
- sometimes it's difficult to anchor to specific end lines due to variations across ROMs, so allow the end line to be blank " " - note this will also remove the trailing blank line so for replacements a trailing \n should be added to maintain spacing; this should be pretty intuitive since you are including the blank line as the end line search
This commit is contained in:
1 parent
45bfc5d602
commit
adc21ed2c3
1 file changed
+10
-2
+10
-2
@@ -254,7 +254,11 @@ replace_section() {
|
||||
begin=`grep -n "$2" $1 | head -n1 | cut -d: -f1`;
|
||||
for end in `grep -n "$3" $1 | cut -d: -f1`; do
|
||||
if [ "$begin" -lt "$end" ]; then
|
||||
sed -i "/${2//\//\\/}/,/${3//\//\\/}/d" $1;
|
||||
if [ "$3" == " " ]; then
|
||||
sed -i "/${2//\//\\/}/,/^\s*$/d" $1;
|
||||
else
|
||||
sed -i "/${2//\//\\/}/,/${3//\//\\/}/d" $1;
|
||||
fi;
|
||||
sed -i "${begin}s;^;${4}\n;" $1;
|
||||
break;
|
||||
fi;
|
||||
@@ -266,7 +270,11 @@ remove_section() {
|
||||
begin=`grep -n "$2" $1 | head -n1 | cut -d: -f1`;
|
||||
for end in `grep -n "$3" $1 | cut -d: -f1`; do
|
||||
if [ "$begin" -lt "$end" ]; then
|
||||
sed -i "/${2//\//\\/}/,/${3//\//\\/}/d" $1;
|
||||
if [ "$3" == " " ]; then
|
||||
sed -i "/${2//\//\\/}/,/^\s*$/d" $1;
|
||||
else
|
||||
sed -i "/${2//\//\\/}/,/${3//\//\\/}/d" $1;
|
||||
fi;
|
||||
break;
|
||||
fi;
|
||||
done;
|
||||
|
||||
Reference in new issue
Block a user