Home | History | Annotate | Download | only in bin
      1 #! /bin/sh
      2 
      3 #
      4 # Simplified findbugs startup script.
      5 # This is an experiment.
      6 #
      7 
      8 program="$0"
      9 
     10 # Follow symlinks until we get to the actual file.
     11 while [ -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
     22 done
     23 
     24 # Assume findbugs home directory is the parent
     25 # of the directory containing the script (which should
     26 # normally be "$findbugs_home/bin").
     27 dir=`dirname "$program"`
     28 findbugs_home="$dir/.."
     29 
     30 # Handle FHS-compliant installations (e.g., Fink)
     31 if [ -d "$findbugs_home/share/findbugs" ]; then
     32 	findbugs_home="$findbugs_home/share/findbugs"
     33 fi
     34 
     35 # Make absolute
     36 findbugs_home=`cd "$findbugs_home" && pwd`
     37 
     38 fb_pathsep=':'
     39 
     40 # Handle cygwin, courtesy of Peter D. Stout
     41 fb_osname=`uname`
     42 if [ `expr "$fb_osname" : CYGWIN` -ne 0 ]; then
     43 	findbugs_home=`cygpath --mixed "$findbugs_home"`
     44 	fb_pathsep=';'
     45 fi
     46 # Handle MKS, courtesy of Kelly O'Hair
     47 if [ "${fb_osname}" = "Windows_NT" ]; then
     48 	fb_pathsep=';'
     49 fi
     50 
     51 if [ ! -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
     56 fi
     57 
     58 # Choose default java binary
     59 fb_javacmd=java
     60 if [ ! -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
     66 fi
     67 
     68 # Default UI is GUI2
     69 fb_launchui="2"
     70 
     71 #
     72 # Stuff we're going to pass to the JVM as JVM arguments.
     73 #
     74 jvm_debug=""
     75 jvm_maxheap="-Xmx768m"
     76 jvm_ea=""
     77 jvm_conservespace=""
     78 jvm_user_props=""
     79 
     80 #
     81 # Process command line args until we hit one we don't recognize.
     82 #
     83 finishedArgs=false
     84 while [ $# -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 
    159 done
    160 
    161 # Extra JVM args for MacOSX.
    162 if [ $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"
    166 fi
    167 
    168 #
    169 # Launch JVM
    170 #
    171 exec "$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