-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrmline.sh
More file actions
executable file
·59 lines (51 loc) · 1.32 KB
/
rmline.sh
File metadata and controls
executable file
·59 lines (51 loc) · 1.32 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
who=`whoami`
tmp_loc=/tmp/rmline_$who
if [ $# -ne 2 -a $# -ne 3 ];then
echo -e "USAGE:\trmline.sh [-r] need_deal_dir source"
exit
fi
# $2 is the file name with the full absolute path
function rm_line() {
local action=$1
local file=$2
local kind=$3
local diff_file=$tmp_loc$file.line
if [ "$action" == "remove" ]; then
mv $file $file.original
if [ "$kind" == "source" ]; then
# more $file.original | sed -e '/^\s*\.line.*$/d' | sed -e '/^\s*\.param.*$/d' | sed -e 's/\/jumbo//' > $file
more $file.original | sed -e '/^\s*\.line.*$/d' | sed -e 's/\/jumbo//' > $file
else
more $file.original | sed -e '/^\s*\.line.*$/d' | sed -e 's/\/jumbo//' > $file
fi
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
echo "$full"
for file in `find $full -name "*.smali"`
do
rm_line $action $file $2
done