1#! /bin/sh 2 3# Launch FindBugs from the command line. 4 5escape_arg() { 6 echo "$1" | sed -e "s,\\([\\\"' ]\\),\\\\\\1,g" 7} 8 9program="$0" 10 11# Follow symlinks until we get to the actual file. 12while [ -h "$program" ]; do 13 link=`ls -ld "$program"` 14 link=`expr "$link" : '.*-> \(.*\)'` 15 if [ "`expr "$link" : '/.*'`" = 0 ]; then 16 # Relative 17 dir=`dirname "$program"` 18 program="$dir/$link" 19 else 20 # Absolute 21 program="$link" 22 fi 23done 24 25# Assume findbugs home directory is the parent 26# of the directory containing the script (which should 27# normally be "$findbugs_home/bin"). 28dir=`dirname "$program"` 29findbugs_home="$dir/.." 30 31# Handle FHS-compliant installations (e.g., Fink) 32if [ -d "$findbugs_home/share/findbugs" ]; then 33 findbugs_home="$findbugs_home/share/findbugs" 34fi 35 36# Make absolute 37findbugs_home=`cd "$findbugs_home" && pwd` 38 39fb_pathsep=':' 40 41# Handle cygwin, courtesy of Peter D. Stout 42fb_osname=`uname` 43if [ `expr "$fb_osname" : CYGWIN` -ne 0 ]; then 44 findbugs_home=`cygpath --mixed "$findbugs_home"` 45 fb_pathsep=';' 46fi 47# Handle MKS, courtesy of Kelly O'Hair 48if [ "${fb_osname}" = "Windows_NT" ]; then 49 fb_pathsep=';' 50fi 51 52if [ ! -d "$findbugs_home" ]; then 53 echo "The path $findbugs_home," 54 echo "which is where I think FindBugs is located," 55 echo "does not seem to be a directory." 56 exit 1 57fi 58 59# Choose default java binary 60fb_javacmd=java 61if [ ! -z "$JAVA_HOME" ] && [ -x "$JAVA_HOME/bin/java" ]; then 62 if [ `expr "$fb_osname" : CYGWIN` -ne 0 ]; then 63 fb_javacmd=`cygpath --mixed "$JAVA_HOME"`/bin/java 64 else 65 fb_javacmd="$JAVA_HOME/bin/java" 66 fi 67fi 68 69 70fb_appjar="$findbugs_home/lib/findbugs.jar" 71 72ShowHelpAndExit() { 73 fb_mainclass="edu.umd.cs.findbugs.ShowHelp" 74 fb_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 exit 0 84} 85 86# Set defaults 87fb_mainclass="edu.umd.cs.findbugs.workflow.FB" 88user_jvmargs='' 89ea_arg='' 90debug_arg='' 91conservespace_arg='' 92workhard_arg='' 93user_props='' 94 95# Handle command line arguments. 96while [ $# -gt 0 ]; do 97 case $1 in 98 -textui) 99 fb_mainclass="edu.umd.cs.findbugs.FindBugs2" 100 ;; 101 102 -jvmArgs) 103 shift 104 user_jvmargs="$1" 105 ;; 106 107 -ea) 108 ea_arg='-ea' 109 ;; 110 111 -maxHeap) 112 shift 113 fb_maxheap="-Xmx$1m" 114 ;; 115 116 -javahome) 117 shift 118 fb_javacmd="$1/bin/java" 119 ;; 120 121 -debug) 122 debug_arg="-Dfindbugs.debug=true" 123 ;; 124 125 -conserveSpace) 126 conservespace_arg="-Dfindbugs.conserveSpace=true" 127 ;; 128 129 -property) 130 shift 131 user_props="-D$1 $user_props" 132 ;; 133 134 -D*=*) 135 user_props="$1 $user_props" 136 ;; 137 138 -version) 139 fb_mainclass=edu.umd.cs.findbugs.Version 140 fb_appargs="-release" 141 while [ $# -gt 0 ]; do 142 shift 143 done 144 fb_javacmd=${fb_javacmd:-"java"} 145fb_maxheap=${fb_maxheap:-"-Xmx768m"} 146fb_appjar=${fb_appjar:-"$findbugs_home/lib/findbugs.jar"} 147set -f 148#echo command: \ 149exec "$fb_javacmd" \ 150 -classpath "$fb_appjar$fb_pathsep$CLASSPATH" \ 151 -Dfindbugs.home="$findbugs_home"\ 152 $fb_maxheap $fb_jvmargs $fb_mainclass ${@:+"$@"} $fb_appargs 153 exit 0 154 ;; 155 156 -help) 157 ShowHelpAndExit 158 ;; 159 160 # All unrecognized arguments will be accumulated and 161 # passed to the application. 162 *) 163 fb_appargs="$fb_appargs `escape_arg "$1"`" 164 ;; 165 esac 166 167 shift 168done 169 170fb_jvmargs="$user_jvmargs $debug_arg $conservespace_arg $workhard_arg $user_props $ea_arg" 171if [ $maxheap ]; then 172 fb_maxheap="-Xmx${maxheap}m" 173fi 174 175# Extra JVM args for MacOSX. 176if [ $fb_osname = "Darwin" ]; then 177 fb_jvmargs="$fb_jvmargs \ 178 -Xdock:name=FindBugs -Xdock:icon=${findbugs_home}/lib/buggy.icns \ 179 -Dapple.laf.useScreenMenuBar=true" 180fi 181 182fb_javacmd=${fb_javacmd:-"java"} 183fb_maxheap=${fb_maxheap:-"-Xmx768m"} 184fb_appjar=${fb_appjar:-"$findbugs_home/lib/findbugs.jar"} 185set -f 186#echo command: \ 187exec "$fb_javacmd" \ 188 -classpath "$fb_appjar$fb_pathsep$CLASSPATH" \ 189 -Dfindbugs.home="$findbugs_home"\ 190 $fb_maxheap $fb_jvmargs $fb_mainclass ${@:+"$@"} $fb_appargs 191 192# vim:ts=3 193