• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#! /bin/sh
2
3# A convenient way to call the main() method of a class
4# in findbugs.jar.
5
6program="$0"
7
8# Follow symlinks until we get to the actual file.
9while [ -h "$program" ]; do
10	link=`ls -ld "$program"`
11	link=`expr "$link" : '.*-> \(.*\)'`
12	if [ "`expr "$link" : '/.*'`" = 0 ]; then
13		# Relative
14		dir=`dirname "$program"`
15		program="$dir/$link"
16	else
17		# Absolute
18		program="$link"
19	fi
20done
21
22# Assume findbugs home directory is the parent
23# of the directory containing the script (which should
24# normally be "$findbugs_home/bin").
25dir=`dirname "$program"`
26findbugs_home="$dir/.."
27
28# Handle FHS-compliant installations (e.g., Fink)
29if [ -d "$findbugs_home/share/findbugs" ]; then
30	findbugs_home="$findbugs_home/share/findbugs"
31fi
32
33# Make absolute
34findbugs_home=`cd "$findbugs_home" && pwd`
35
36fb_pathsep=':'
37
38# Handle cygwin, courtesy of Peter D. Stout
39fb_osname=`uname`
40if [ `expr "$fb_osname" : CYGWIN` -ne 0 ]; then
41	findbugs_home=`cygpath --mixed "$findbugs_home"`
42	fb_pathsep=';'
43fi
44# Handle MKS, courtesy of Kelly O'Hair
45if [ "${fb_osname}" = "Windows_NT" ]; then
46	fb_pathsep=';'
47fi
48
49if [ ! -d "$findbugs_home" ]; then
50	echo "The path $findbugs_home,"
51	echo "which is where I think FindBugs is located,"
52	echo "does not seem to be a directory."
53	exit 1
54fi
55
56# Choose default java binary
57fb_javacmd=java
58if [ ! -z "$JAVA_HOME" ] && [ -x "$JAVA_HOME/bin/java" ]; then
59	if [ `expr "$fb_osname" : CYGWIN` -ne 0 ]; then
60		fb_javacmd=`cygpath --mixed "$JAVA_HOME"`/bin/java
61	else
62		fb_javacmd="$JAVA_HOME/bin/java"
63	fi
64fi
65
66if [ $# -eq 0 ]; then
67	echo "Usage: fbwrap <main class name> <args...>"
68	exit 1
69fi
70
71fb_mainclass="$1"
72shift
73
74fb_javacmd=${fb_javacmd:-"java"}
75fb_maxheap=${fb_maxheap:-"-Xmx768m"}
76fb_appjar=${fb_appjar:-"$findbugs_home/lib/findbugs.jar"}
77set -f
78#echo command: \
79exec "$fb_javacmd" \
80	-classpath "$fb_appjar$fb_pathsep$CLASSPATH" \
81	-Dfindbugs.home="$findbugs_home"\
82	$fb_maxheap $fb_jvmargs $fb_mainclass ${@:+"$@"} $fb_appargs
83
84# vim:ts=3
85