AK3+Backend: cleanups, update *_line functions
- touch up a couple pesky minor things - add global scope to replace_line and remove_line so they match replace_string, and can now work on all matches found in a file
This commit is contained in:
2 files changed
+16
-8
No files matched your search
@@ -90,7 +90,7 @@ umount_apex() {
|
|||||||
local dest loop;
|
local dest loop;
|
||||||
for dest in $($BB find /apex -type d -mindepth 1 -maxdepth 1); do
|
for dest in $($BB find /apex -type d -mindepth 1 -maxdepth 1); do
|
||||||
if [ -f $dest.img ]; then
|
if [ -f $dest.img ]; then
|
||||||
loop=$($BB mount | $BB grep $dest | $BB cut -d" " -f1);
|
loop=$($BB mount | $BB grep $dest | $BB cut -d\ -f1);
|
||||||
fi;
|
fi;
|
||||||
($BB umount -l $dest;
|
($BB umount -l $dest;
|
||||||
$BB losetup -d $loop) 2>/dev/null;
|
$BB losetup -d $loop) 2>/dev/null;
|
||||||
|
|||||||
+15
-7
@@ -15,7 +15,7 @@ split_img=$home/split_img;
|
|||||||
# ui_print "<text>" [...]
|
# ui_print "<text>" [...]
|
||||||
ui_print() {
|
ui_print() {
|
||||||
until [ ! "$1" ]; do
|
until [ ! "$1" ]; do
|
||||||
echo -e "ui_print $1
|
echo "ui_print $1
|
||||||
ui_print" >> /proc/self/fd/$OUTFD;
|
ui_print" >> /proc/self/fd/$OUTFD;
|
||||||
shift;
|
shift;
|
||||||
done;
|
done;
|
||||||
@@ -520,19 +520,27 @@ insert_line() {
|
|||||||
fi;
|
fi;
|
||||||
}
|
}
|
||||||
|
|
||||||
# replace_line <file> <line replace string> <replacement line>
|
# replace_line <file> <line replace string> <replacement line> <scope>
|
||||||
replace_line() {
|
replace_line() {
|
||||||
|
local lines line;
|
||||||
if grep -q "$2" $1; then
|
if grep -q "$2" $1; then
|
||||||
local line=$(grep -n "$2" $1 | head -n1 | cut -d: -f1);
|
lines=$(grep -n "$2" $1 | cut -d: -f1 | sort -nr);
|
||||||
sed -i "${line}s;.*;${3};" $1;
|
[ "$4" == "global" ] || lines=$(echo "$lines" | tail -n1);
|
||||||
|
for line in $lines; do
|
||||||
|
sed -i "${line}s;.*;${3};" $1;
|
||||||
|
done;
|
||||||
fi;
|
fi;
|
||||||
}
|
}
|
||||||
|
|
||||||
# remove_line <file> <line match string>
|
# remove_line <file> <line match string> <scope>
|
||||||
remove_line() {
|
remove_line() {
|
||||||
|
local lines line;
|
||||||
if grep -q "$2" $1; then
|
if grep -q "$2" $1; then
|
||||||
local line=$(grep -n "$2" $1 | head -n1 | cut -d: -f1);
|
lines=$(grep -n "$2" $1 | cut -d: -f1 | sort -nr);
|
||||||
sed -i "${line}d" $1;
|
[ "$3" == "global" ] || lines=$(echo "$lines" | tail -n1);
|
||||||
|
for line in $lines; do
|
||||||
|
sed -i "${line}d" $1;
|
||||||
|
done;
|
||||||
fi;
|
fi;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user