-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreplace_alt_keywords.sh
executable file
·58 lines (42 loc) · 1.4 KB
/
replace_alt_keywords.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
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
. $BIOC/utils/replace_biocLite.sh
INST_REPOS="biocinstallRepos"
BIOC_VALID="biocValid"
BIOC_VERS="biocVersion"
BIOC_INST="BiocInstaller"
NS="NAMESPACE"
SOURCE_FILES=".*\(\.R\|$NS\|\.[Rr][NnMm][WwDd]\|\.[Rr][Dd]\)"
instrepos_hits=`find . ! -path . -regex "$SOURCE_FILES" -exec grep -wl "$INST_REPOS" {} \+`
if [ ! -z "${instrepos_hits// }" ]; then
echo "Replacing any biocinstallRepos with BiocManager::repositories..."
for i in $instrepos_hits;
do
sed -i "s/\<$INST_REPOS\>/repositories/" $i
sed -i "s/\<$BIOC_INST\>/BiocManager/g" $i
done
fi
biocvalid_hits=`find . ! -path . -regex "$SOURCE_FILES" -exec grep -wl "$BIOC_VALID" {} \+`
if [ ! -z "${biocvalid_hits// }" ]; then
echo "Replacing any biocValid with BiocManager::valid..."
for i in $biocvalid_hits;
do
sed -i "s/\<$BIOC_VALID\>/valid/" $i
done
fi
biocvers_hits=`find . ! -path . -regex "$SOURCE_FILES" -exec grep -wl "$BIOC_VERS" {} \+`
if [ ! -z "${biocvers_hits// }" ]; then
echo "Replacing any biocVersion with BiocManager::version"
for i in $biocvers_hits;
do
sed -i "s/\<$BIOC_VERS\>/version/" $i
done
fi
ALT_FILES="$instrepos_hits $biocvalid_hits $biocvers_hits"
TOT_FILES="$LITE_FILES $ALT_FILES"
if [ -z "${TOT_FILES// }" ]; then
exit 0
else
TOTAL=`echo $TOT_FILES | tr " " "\n" | uniq | wc -l`
echo "Done. $TOTAL file(s) modified."
exit 1
fi