aboutsummaryrefslogtreecommitdiff
path: root/dev/tools
diff options
context:
space:
mode:
authorThéo Zimmermann2019-06-06 11:22:09 +0200
committerThéo Zimmermann2019-06-17 18:08:32 +0200
commit1a9c769ed363ee2f2784e7252af72e6c1e2fbcc6 (patch)
treefd541cee60cbab8da21f69591209363e414183bd /dev/tools
parent35472e260eb609438eda7de9744a104ef8ef906d (diff)
Adapt change-header script to handle shebangs in addition to Emacs comments.
Remove other types of lines before copyright headers.
Diffstat (limited to 'dev/tools')
-rwxr-xr-xdev/tools/change-header19
1 files changed, 8 insertions, 11 deletions
diff --git a/dev/tools/change-header b/dev/tools/change-header
index 472a075dbd..59c6f43958 100755
--- a/dev/tools/change-header
+++ b/dev/tools/change-header
@@ -13,22 +13,19 @@ newheader=$2
if [ ! -f $oldheader ]; then echo Cannot read file $oldheader; exit 1; fi
if [ ! -f $newheader ]; then echo Cannot read file $newheader; exit 1; fi
-n=`wc -l $oldheader | sed -e "s/ *\([0-9]*\).*/\1/g"`
-nsucc=`expr $n + 1`
-
-linea='(* -*- coding:utf-8 -*- *)'
-lineb='(* -*- compile-command: "make -C ../.. bin/coqdoc" -*- *)'
+n=$(wc -l $oldheader | sed -e "s/ *\([0-9]*\).*/\1/g")
+nsucc=$(expr $n + 1)
modified=0
kept=0
for i in $(git grep --name-only --fixed-strings "$(head -1 $oldheader)"); do
- headline=`head -n 1 $i`
- if `echo $headline | grep "(\* -\*- .* \*)" > /dev/null`; then
- # Has emacs header
+ headline=$(head -n 1 $i)
+ if $(echo $headline | grep "(\* -\*- .* \*)" > /dev/null) || $(echo $headline | grep "^#\!" > /dev/null); then
+ # Has header
head -n +$nsucc $i | tail -n $n > $i.head.tmp$$
hasheadline=1
- nnext=`expr $nsucc + 1`
+ nnext=$(expr $nsucc + 1)
else
head -n +$n $i > $i.head.tmp$$
hasheadline=0
@@ -44,9 +41,9 @@ for i in $(git grep --name-only --fixed-strings "$(head -1 $oldheader)"); do
cat $newheader >> $i.tmp$$
tail -n +$nnext $i >> $i.tmp$$
mv $i.tmp$$ $i
- modified=`expr $modified + 1`
+ modified=$(expr $modified + 1)
else
- kept=`expr $kept + 1`
+ kept=$(expr $kept + 1)
fi
rm $i.head.tmp$$
done