AK2: automatically escape forward slashes (/) for section functions
- use simple replacement to automatically escape forward slashes (/) to make remove_section and replace_section perform like the other functions, since they are needed as part of a sed /pattern/,/pattern/d delete operation - update documentation
This commit is contained in:
1 parent
fc41148d62
commit
d0a43839fe
2 files changed
+2
-4
No files matched your search
@@ -54,8 +54,6 @@ Similarly, "line match string" and "line replace string" are the search strings
|
||||
|
||||
You may also use ui_print "<text>" to write messages back to the recovery during the modification process, and contains "<string>" "<substring>" to simplify string testing logic you might want in your script.
|
||||
|
||||
Note: the "begin search string" and "end search string" arguments of replace_section and remove_section require any forward slashes (/) to be escaped.
|
||||
|
||||
// Instructions
|
||||
|
||||
1- Place zImage in the root (dtb should also go here for devices that require a custom one, both will fallback to the original if not included)
|
||||
|
||||
+2
-2
@@ -116,13 +116,13 @@ replace_string() {
|
||||
# replace_section <file> <begin search string> <end search string> <replacement string>
|
||||
replace_section() {
|
||||
line=`grep -n "$2" $1 | cut -d: -f1`;
|
||||
sed -i "/${2}/,/${3}/d" $1;
|
||||
sed -i "/${2//\//\\/}/,/${3//\//\\/}/d" $1;
|
||||
sed -i "${line}s;^;${4}\n;" $1;
|
||||
}
|
||||
|
||||
# remove_section <file> <begin search string> <end search string>
|
||||
remove_section() {
|
||||
sed -i "/${2}/,/${3}/d" $1;
|
||||
sed -i "/${2//\//\\/}/,/${3//\//\\/}/d" $1;
|
||||
}
|
||||
|
||||
# insert_line <file> <if search string> <before|after> <line match string> <inserted line>
|
||||
|
||||
Reference in new issue
Block a user