From d0a43839fea4b5ef8e4b6d0278c87790eb3a1c0d Mon Sep 17 00:00:00 2001 From: osm0sis Date: Fri, 1 Jul 2016 12:35:42 -0300 Subject: [PATCH] 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 --- README | 2 -- anykernel.sh | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/README b/README index b88fa14..2a7f3b3 100644 --- a/README +++ b/README @@ -54,8 +54,6 @@ Similarly, "line match string" and "line replace string" are the search strings You may also use ui_print "" to write messages back to the recovery during the modification process, and contains "" "" 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) diff --git a/anykernel.sh b/anykernel.sh index cb63d95..5c8d6d1 100755 --- a/anykernel.sh +++ b/anykernel.sh @@ -116,13 +116,13 @@ replace_string() { # replace_section 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 remove_section() { - sed -i "/${2}/,/${3}/d" $1; + sed -i "/${2//\//\\/}/,/${3//\//\\/}/d" $1; } # insert_line