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