-
Notifications
You must be signed in to change notification settings - Fork 24
/
openjump
executable file
·42 lines (33 loc) · 1.4 KB
/
openjump
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
#!/bin/sh
root="$(git rev-parse --show-toplevel)"
[ -d "$root" ] || exit 1
owndir="$(cd "$(dirname "$0")"; pwd -P)"
beginswith() { case "$2" in "$1"*) true;; *) false;; esac; }
checkfile() {
beginswith "$root/" "$1" || [ -f "$root/$1" ]
}
"$owndir"/xml "$1"
# check all referenced files
{
cat "$1" | grep -A1 -F '<key class="javax.xml.namespace.QName">Project File</key>' | grep -F '<value class="java.lang.String">' | sed -E 's/^.*>(.*)<.*$/\1/'
cat "$1" | grep -A1 -F '<key class="java.lang.String">File</key>' | grep -F '<value class="java.lang.String">' | sed -E 's/^.*>(.*)<.*$/\1/'
cat "$1" | grep -F '<query>' | grep -F '</query>' | sed -E 's/^.*>(.*)<.*$/\1/'
} | {
failed=0
while IFS= read -r file ; do
checkfile "$file" || {
echo >&2 "openjump: \`$1' references a file that is not under the git root: \`$file'"
failed=1
}
done
exit $failed
} || exit 1
# remove $root from the file
sed -i "$1" -e 's/'"$(echo "$root/" | sed -e 's/[]\/$*.^|[]/\\&/g')"'/.\//g'
sed -E '/<windowLocation / d' -i "$1"
sed -E '/<windowSize / d' -i "$1"
sed -E '/<windowZoom / d' -i "$1"
sed -E '/<maximized>(true|false)<\/maximized>/ d' -i "$1"
sed -E 's/<([^>]*)editable="(true|false)"([^>]*)>/<\1\3>/ig' -i "$1"
sed -E 's/<([^>]*)selectable="(true|false)"([^>]*)>/<\1\3>/ig' -i "$1"
"$owndir"/xml "$1"