Merged gcj-eclipse branch to trunk.
[official-gcc.git] / libjava / classpath / scripts / loc
blobdc2f327035fd0d49baa8b196b6298a4de0d1d2c0
1 #!/bin/sh
3 # loc Find a class or package
5 # Usage: loc [-l] class-pattern [dirname]
7 # -l Use system locate command instead of find. In that case, loc
8 # will ignore any directory to be searched.
10 # Example:
12 # $ loc -l org.objectweb.jonas.common.JProp
13 # /var/lib/jonas/demoserver/ejbjars/autoload/mejb.jar
14 # /var/lib/jonas/lib/common/ow_jonas_bootstrap.jar
15 # /var/lib/jonas/eclipseserver/ejbjars/autoload/mejb.jar
16 # /var/lib/jonas/ejbjars/autoload/mejb.jar
17 # /var/cache/jonas/work/ejbjars/jonas/mejb_2005.09.15-17.01.52.jar
18 # /usr/src/redhat/BUILD/jonas-4.3.3/jonas/classes/common/org/objectweb/jonas/common/JProp.class
21 MODE=$1
22 if test "$MODE" == "-l"; then
23 COMMAND='(locate \*.jar ; locate \*.war)'
24 shift
25 else
26 COMMAND='(find "$FOO" -name \*.jar -follow ; find "$FOO" -name \*.war -follow)'
29 FOO=$2
30 if test "x$FOO" == "x"; then
31 FOO=/usr/share/java
34 eval "$COMMAND" 2>/dev/null | while read i; do
35 if (fastjar tf $i 2>/dev/null | grep $1) > /dev/null 2>&1 ; then
36 echo $i
38 done
40 if test "$MODE" != "-l"; then
41 find "$FOO" -name '*.class' 2>/dev/null | grep $1
42 else
43 locate \*.class | grep $1