-
Notifications
You must be signed in to change notification settings - Fork 273
/
abe
executable file
·78 lines (67 loc) · 2.25 KB
/
abe
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/sh
command -v cygpath >/dev/null 2>&1
on_cygwin=$(( $? == 0 ? 1 : 0 ))
# below, we use non-environment variables to avoid implicitly updating the
# environment with UNIX versions of paths.
if [ "$on_cygwin" = 1 ] && [ "$JAVA" ]; then
java=$(cygpath --unix "$JAVA")
else
java=$JAVA
fi
if [ "$on_cygwin" = 1 ] && [ "$JAVA_HOME" ]; then
java_home=$(cygpath --unix "$JAVA_HOME")
else
java_home=$JAVA_HOME
fi
# honor JAVA environment variable if set; if not, use JAVA_HOME (if it's set);
# if not, fall back to the old hardcoded default.
: "${java:=${java_home:-/usr}/bin/java}"
# Follow symlinks, if we have readlink available; this will allow a symlink to
# the real wrapper script's location to be installed somewhere on the PATH (ie.
# /usr/local/bin/abe, or $HOME/bin/abe).
#
# This technique has flaws. See http://mywiki.wooledge.org/BashFAQ/028 to
# understand its limitations before reusing it in your own scripts.
executable=$0
if command -v readlink >/dev/null 2>&1; then
while target=$(readlink "$executable"); do
[ "$executable" = "$target" ] && break # avoid endless loops
executable=$target
done
fi
basedir=$(dirname "$executable")
cp=$basedir:$basedir/bin:$basedir/abe.jar
for f in $basedir/lib/*.jar; do
# note that this technique only works as long as nullglob is disabled
# (which it is, by default, on all POSIX shells); we're relying on the
# *.jar glob expression returning literally '*.jar' as a result when no
# matches exist on-disk.
[ -e "$f" ] || {
echo "WARNING: No jars found in lib directory. Please download a BouncyCastle implementation per the README (looking for: $f)" >&2
continue
}
cp=$cp:$f
done
[ -e "$basedir/abe.jar" ] || {
echo "ERROR: Could not find abe.jar in $basedir; did you run ant to compile?" >&2
exit 1
}
[ -e "$java" ] || {
echo "ERROR: Could not find java executable at $java" >&2
exit 1
}
if [ "$on_cygwin" = 1 ]; then
# convert classpath from UNIX to Windows paths
unix_cp=$cp
IFS=:
set -f
cp=
for element in $unix_cp; do
[ "$element" ] || continue
cp="$cp;$(cygpath --windows "$element")"
done
fi
# Using "exec" here replaces the script's process table entry with that of the
# JVM, avoiding the need to keep the script in memory while the executable
# runs.
exec "$java" -cp "$cp" org.nick.abe.Main "$@"