Ticket #3376: lgrep

File lgrep, 859 bytes (added by monni, 16 years ago)

Library Grep - lgrep

Line 
1#!/bin/sh
2
3usage() {
4 echo `basename $0` \[-V\] \<symbol\>
5 echo \- list files containing \<symbol\>
6 echo " -V lists also directories searched"
7 echo ""
8 echo `basename $0` -h
9 echo \- Show this help
10 exit 0
11}
12
13if [ "$1" == "-V" ]; then
14 VERBOSE=1
15 shift
16else
17 VERBOSE=0
18fi
19
20if [ "$1" == "-h" ]; then
21 usage
22fi
23
24if [ "x$1" == "x" ]; then
25 usage
26fi
27
28LPATH=`echo $LIBRARY_PATH|sed "s|%A/lib:||"`
29[ -d ./lib ] && LPATH="./lib:$LPATH" || true
30LPATH=`echo $LPATH|sed "s/:/ /g"`
31TEMPFILE=/boot/var/tmp/`basename $0`.$PPID
32for libdir in `echo $LPATH`; do
33 if [ "$VERBOSE" == "1" ]; then
34 echo Searching in \"$libdir\"...
35 fi
36 for lib in $libdir/*.so ; do
37 echo "[ $lib ]" > $TEMPFILE
38 (nm -D $lib 2>/dev/null)|grep $1 >> $TEMPFILE
39 LINES=`wc -l $TEMPFILE | awk '{ print $1; }'`
40 if [ "$LINES" != "1" ]; then
41 cat $TEMPFILE
42 fi
43 done
44done
45rm -f $TEMPFILE