-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdo_header
executable file
·43 lines (34 loc) · 1.16 KB
/
do_header
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
#! /bin/sh
#
# do_header
#
# Script para actualizar las cabeceras automáticamente cuando sea necesario.
#
tmp_header="/tmp/header$$.tmp"
hash_lines=`wc -l template.hash | cut -f1 -d' '`
header_lines=`wc -l template.h | cut -f1 -d' '`
for file in *.c *.h Makefile; do
test -r $file -a -w $file || continue
case "$file" in
template*) continue ;;
Makefile) template_file="template.hash"
lines=$hash_lines;
;;
*) template_file="template.h"
lines=$header_lines
;;
esac
sed -e "$lines q" $file >$tmp_header
if diff $tmp_header $template_file >/dev/null 2>&1; then
# Cabeceras iguales
echo "El fichero $file no necestia actualización."
else
# Cabeceras distintas. Reemplazar
tfile="$file.s"
echo "Actualizando $file."
sed -e '0,/^[ ]*$/d' $file >$tfile
cat $template_file $tfile >$file
rm $tfile
fi
done
rm -f $tmp_header