-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhaskell-same
More file actions
executable file
·41 lines (36 loc) · 846 Bytes
/
haskell-same
File metadata and controls
executable file
·41 lines (36 loc) · 846 Bytes
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
#!/usr/bin/env sh
#: A quick script to find common code between two Haskell files.
#:
#: Usage:
#:
#: haskell-same FILE1 FILE2
TEMPFILE="$(mktemp)"
# Ignore lines with only whitespace
# Ignore certain comments
# Ignore imports
# Ignore pragmas
# Ignore very short lines
same --ignore-all-space $1 $2 \
| grep -v '^ *$' \
| grep -v '^-----' \
| grep -v '^-- Copyright' \
| grep -v '^-- License' \
| grep -v '^-- Maintainer' \
| grep -v '^-- Stability' \
| grep -v '^-- Portability' \
| grep -v '^-- QuickCheck tests' \
| grep -v '^import' \
| grep -v '^ *(.*) *$' \
| grep -v '^\{-#' \
| grep -v '^ ) where' \
| grep -v 'test :: Test' \
| sed -r '/^ *.{,5} *$/d' > ${TEMPFILE}
numWords=$(cat ${TEMPFILE} | wc -w)
if [ ${numWords} -gt 10 ]
then
cat ${TEMPFILE}
exit 1
else
exit 0
fi
rm ${TEMPFILE}