-
Notifications
You must be signed in to change notification settings - Fork 126
/
rmline.sh
executable file
·46 lines (40 loc) · 1.09 KB
/
rmline.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
who=`whoami`
tmp_loc=/tmp/rmline_$who
# $2 is the file name with the full absolute path
function rm_line() {
local action=$1
local file=$2
local diff_file=$tmp_loc$file.line
if [ "$action" == "remove" ]; then
mv $file $file.original
more $file.original | sed -e '/^\s*\.line.*$/d' | sed -e 's/\/jumbo//' > $file
diff $file $file.original > /dev/null || {
mkdir -p `dirname $diff_file`
diff -B -c $file $file.original > $diff_file
}
rm $file.original
else
if [ -f $diff_file ]; then
patch -f $file -r /dev/null < $diff_file >/dev/null 2>&1
rm -f $diff_file
else
echo "Warning: line info file ($diff_file) does not exist" >&2
fi
fi
}
action=remove
if [ "$1" == "-r" ]; then
action=add
shift
fi
p=`pwd`
full=`echo $1 | sed -e "s#\(^[^\/]\)#$p/\1#"`
if [ -f "$full" ]; then
echo $full | grep .smali$ > /dev/null && rm_line $action $full
exit 0
fi
for file in `find $full -name "*.smali"`
do
rm_line $action $file
done