-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy path90.diff.sh
executable file
·57 lines (54 loc) · 1.14 KB
/
90.diff.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
#
# (C) Copyright 2017 Hojin Choi <[email protected]>
#
# vim: ts=4 noexpandtab sw=4 sts=4
mkdir -p ./tmp
. sejongrc
count=0
newcount=0
while read INFILE1
do
count=$((count + 1))
FILE=${INFILE1##*/}
INFILE2=corpus-utf8/$FILE
echo -n -e "Comparing $INFILE1 $INFILE2\r"
if cmp $INFILE1 $INFILE2; then
:
else
INFILE3=./tmp/$FILE
cp "$INFILE1" "$INFILE3"
patch_preexists "$INFILE3"
if cmp $INFILE3 $INFILE2; then
echo "$INFILE3" "$INFILE2" identical
echo ""
rm -f "$INFILE3"
continue
fi
idx=0
while true
do
PATCHFILE=patches/${FILE%.txt}-$(printf %03d $idx).patch
if test -f $PATCHFILE; then
idx=$(( idx + 1 ))
continue
fi
break
done
newcount=$((newcount + 1))
diff -u --label=old/$FILE $INFILE3 --label=new/$FILE $INFILE2 | tee $PATCHFILE
rm -f "$INFILE3"
echo "Patch file: $PATCHFILE created"
echo "=============================================="
fi
done <<EOT
$(find corpus-utf8.orig -name '*.txt')
EOT
echo ""
echo "$count files scanned.."
if test "$newcount" -gt 0; then
echo "Add newly created patch files to git, please"
echo "git add patches"
else
echo "No new diff found"
fi