1#! /bin/sh
2
3#
4# Simplified findbugs startup script.
5# This is an experiment.
6#
7
8program="$0"
9
10# Follow symlinks until we get to the actual file.
11while [ -h "$program" ]; do
12	link=`ls -ld "$program"`
13	link=`expr "$link" : '.*-> \(.*\)'`
14	if [ "`expr "$link" : '/.*'`" = 0 ]; then
15		# Relative
16		dir=`dirname "$program"`
17		program="$dir/$link"
18	else
19		# Absolute
20		program="$link"
21	fi
22done
23
24# Assume findbugs home directory is the parent
25# of the directory containing the script (which should
26# normally be "$findbugs_home/bin").
27dir=`dirname "$program"`
28findbugs_home="$dir/.."
29
30# Handle FHS-compliant installations (e.g., Fink)
31if [ -d "$findbugs_home/share/findbugs" ]; then
32	findbugs_home="$findbugs_home/share/findbugs"
33fi
34
35# Make absolute
36findbugs_home=`cd "$findbugs_home" && pwd`
37
38fb_pathsep=':'
39
40# Handle cygwin, courtesy of Peter D. Stout
41fb_osname=`uname`
42if [ `expr "$fb_osname" : CYGWIN` -ne 0 ]; then
43	findbugs_home=`cygpath --mixed "$findbugs_home"`
44	fb_pathsep=';'
45fi
46# Handle MKS, courtesy of Kelly O'Hair
47if [ "${fb_osname}" = "Windows_NT" ]; then
48	fb_pathsep=';'
49fi
50
51if [ ! -d "$findbugs_home" ]; then
52	echo "The path $findbugs_home,"
53	echo "which is where I think FindBugs is located,"
54	echo "does not seem to be a directory."
55	exit 1
56fi
57
58# Choose default java binary
59fb_javacmd=java
60if [ ! -z "$JAVA_HOME" ] && [ -x "$JAVA_HOME/bin/java" ]; then
61	if [ `expr "$fb_osname" : CYGWIN` -ne 0 ]; then
62		fb_javacmd=`cygpath --mixed "$JAVA_HOME"`/bin/java
63	else
64		fb_javacmd="$JAVA_HOME/bin/java"
65	fi
66fi
67
68# Default UI is GUI2
69fb_launchui="2"
70
71#
72# Stuff we're going to pass to the JVM as JVM arguments.
73#
74jvm_debug=""
75jvm_maxheap="-Xmx768m"
76jvm_ea=""
77jvm_conservespace=""
78jvm_user_props=""
79
80#
81# Process command line args until we hit one we don't recognize.
82#
83finishedArgs=false
84while [ $# -gt 0 ] && [ "$finishedArgs" = "false" ]; do
85
86	arg=$1
87
88	case $arg in
89		-textui)
90			shift
91			fb_launchui="0"
92			;;
93
94		-gui)
95			shift
96			fb_launchui="2"
97			;;
98
99		-gui1)
100			shift
101			fb_launchui="1"
102			;;
103
104		-maxHeap)
105			shift
106			jvm_maxheap="-Xmx$1m"
107			shift
108			;;
109
110		-ea)
111			shift
112			jvm_ea="-ea"
113			;;
114
115		-javahome)
116			shift
117			fb_javacmd="$1/bin/java"
118			shift
119			;;
120
121		-debug)
122			shift
123			jvm_debug="-Dfindbugs.debug=true"
124			;;
125
126		-conserveSpace)
127			shift
128			jvm_conservespace="-Dfindbugs.conserveSpace=true"
129			;;
130
131		-property)
132			shift
133			jvm_user_props="-D$1 $jvm_user_props"
134			shift
135			;;
136
137		-D*=*)
138			jvm_user_props="$1 $user_props"
139			shift
140			;;
141
142		-version)
143			shift
144			fb_launchui="version"
145			;;
146
147		-help)
148			shift
149			fb_launchui="help"
150			;;
151
152		# All arguments starting from the first unrecognized arguments
153		# are passed on to the Java app.
154		*)
155			finishedArgs=true
156			;;
157	esac
158
159done
160
161# Extra JVM args for MacOSX.
162if [ $fb_osname = "Darwin" ]; then
163	fb_jvmargs="$fb_jvmargs \
164		-Xdock:name=FindBugs -Xdock:icon=${findbugs_home}/lib/buggy.icns \
165		-Dapple.laf.useScreenMenuBar=true"
166fi
167
168#
169# Launch JVM
170#
171exec "$fb_javacmd" \
172	-classpath "$fb_appjar$fb_pathsep$CLASSPATH" \
173	-Dfindbugs.home="$findbugs_home" \
174	$jvm_debug $jvm_maxheap $jvm_ea $jvm_conservespace $jvm_user_props \
175	-Dfindbugs.launchUI=$fb_launchui \
176	-jar $findbugs_home/lib/findbugs.jar \
177	${@:+"$@"}
178