-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgrand-replace.sh
executable file
·149 lines (122 loc) · 3.63 KB
/
grand-replace.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# grand-replace.sh - copyright years updating script
# invoke as grand-replace.sh $dir or grand-replace.sh --list $dir or
# grand-replace.sh --missed $dir
# list files that have possibly been missed by this script
find_missed () {
find . \
-name autom4te.cache -prune -o \
-name .git -prune -o \
-wholename ./tta/maintain/lib -prune -o \
-name test -prune -o \
-name "test-infodir" -prune -o \
-name "gnulib" -prune -o \
-name "po" -prune -o \
-name "po_document" -prune -o \
-name "build-aux" -prune -o \
-name "contrib" -prune -o \
-wholename "./js/node_modules" -prune -o \
-wholename "./tta/t/results" -prune -o \
-wholename "./tta/tests/*/{res,out}_*" -prune -o \
-type f \
\( -name '*' \) \
-not -name 'Makefile.in' \
-not -name Makefile \
-not -name "*.m4" \
-not -name "*.sh.log" \
-not -name "libtool" \
-not -name configure \
-not -name "config.*" \
-not -name "*.info" \
-not -name "*.info-?" \
-not -wholename "./doc/txi-??.tex" \
-not -wholename "./doc/texinfo-ja.tex" \
-not -wholename "./doc/texinfo-zh.tex" \
-not -wholename "./doc/short-sample-*.texi" \
-not -wholename "./doc/refcard/txirefcard.tex" \
-not -wholename "./doc/texi2oldapi.texi" \
-not -wholename "./texindex/ti.texi" \
-not -name "ChangeLog.*" \
-not -name "COPYING" \
-not -name "fdl.texi" \
-not -wholename "./tta/texi2any" \
-not -wholename "./util/htmlxref.cnf" \
-not -wholename "./Pod-Simple-Texinfo/pod2texi" \
-not -wholename "./install-info/tests/defs" \
-not -wholename "./INSTALL.generic" \
-not -name "*~" \
-exec perl -wnl -e '/20\d[^5] Free/ && print "$ARGV:$_"' '{}' \;
}
change_files () {
if $list ; then
find $find_dir -regextype posix-egrep $prune -o $not -type f \
\( -regex "$ext_pattern" -o -regex "$named_pattern" \) \
-print
else
find $find_dir -regextype posix-egrep $prune -o $not -type f \
\( -regex "$ext_pattern" -o -regex "$named_pattern" \) \
-execdir perl -wpli -e \
's/-20\d\d Free/-'$current_year' Free/;
s/(Copyright 20\d\d) Free/$1-'$current_year' Free/;' \
'{}' ';'
fi
}
list=false
missed=false
case $1 in --list)
list=true
shift;;
--missed)
missed=true
shift;;
esac
dir=$1
if ! test -d "$dir" ; then
echo "no argument" >&2
exit 1
fi
cd $dir
if $missed ; then find_missed ; exit 0 ; fi
current_year=`date "+%Y"`
prune_dirs="./tta/maintain/lib|./tta/tests/test_scripts|./gnulib|./tta/gnulib|./js/node_modules|./contrib|./tta/t/include"
prune="-regex ($prune_dirs) -prune"
# Don't touch this file itself
not="-not -name grand-replace.sh"
find_dir=.
extensions='c|h|sh|pm|pl|texi|xs'
named_files='configure.ac|Makefile.am|README|README-hacking|TODO'
ext_pattern=".*\.($extensions)"
named_pattern=".*\/($named_files)"
change_files
find_dir=.
ext_pattern=""
named_pattern='./NEWS|./INSTALL|./AUTHORS|./js/info.js|./pre-inst-env'
change_files
find_dir=contrib/nontests
prune_dirs=""
ext_pattern=".*\.(sh|test)"
named_files='README|txitextest'
named_pattern=".*\/($named_files)"
change_files
find_dir=contrib/mass_test
prune_dirs=""
ext_pattern=".*\.(sh)"
change_files
find_dir=util
ext_pattern=""
named_pattern=".*"
# update these manually for now
not='-not -name htmlxref.cnf -not -name texi2dvi -not -name texi2pdf'
change_files
find_dir=tta/Texinfo
extensions='txt|awk'
ext_pattern=".*\.($extensions)"
named_files=""
named_pattern=".*\/($named_files)"
change_files
find_dir=man
extensions='1|5|h2m'
named_files=''
ext_pattern=".*\.($extensions)"
named_pattern=".*\/($named_files)"
change_files
exit 0