mirror of
https://github.com/yann64/haikuports.git
synced 2026-04-22 11:40:06 +02:00
Initial addition of hgrep and lgrep scripts from http://dev.haiku-os.org/ticket/3376
TODO make use of finddir where useful, perhaps nicer usage displays.
This commit is contained in:
10
sys-apps/hgrep/hgrep
Executable file
10
sys-apps/hgrep/hgrep
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright 2011, Haiku, Inc. All Rights Reserved.
|
||||
# Distributed under the terms of the MIT License.
|
||||
#
|
||||
|
||||
find $(finddir B_COMMON_DEVEOP_DIRECTORY/headers -type f -print0 | xargs -0 egrep "$@"
|
||||
|
||||
# TODO add other header directories to search?
|
||||
50
sys-apps/lgrep/lgrep
Executable file
50
sys-apps/lgrep/lgrep
Executable file
@@ -0,0 +1,50 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright 2011, Haiku, Inc. All Rights Reserved.
|
||||
# Distributed under the terms of the MIT License.
|
||||
#
|
||||
|
||||
usage() {
|
||||
echo `basename $0` \[-V\] \<symbol\>
|
||||
echo \- list files containing \<symbol\>
|
||||
echo " -V lists also directories searched"
|
||||
echo ""
|
||||
echo `basename $0` -h
|
||||
echo \- Show this help
|
||||
exit 0
|
||||
}
|
||||
|
||||
if [ "$1" == "-V" ]; then
|
||||
VERBOSE=1
|
||||
shift
|
||||
else
|
||||
VERBOSE=0
|
||||
fi
|
||||
|
||||
if [ "$1" == "-h" ]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
if [ "x$1" == "x" ]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
LPATH=`echo $LIBRARY_PATH|sed "s|%A/lib:||"`
|
||||
[ -d ./lib ] && LPATH="./lib:$LPATH" || true
|
||||
LPATH=`echo $LPATH|sed "s/:/ /g"`
|
||||
TEMPFILE=/boot/var/tmp/`basename $0`.$PPID
|
||||
for libdir in `echo $LPATH`; do
|
||||
if [ "$VERBOSE" == "1" ]; then
|
||||
echo Searching in \"$libdir\"...
|
||||
fi
|
||||
for lib in $libdir/*.so ; do
|
||||
echo "[ $lib ]" > $TEMPFILE
|
||||
(nm -D $lib 2>/dev/null)|grep $1 >> $TEMPFILE
|
||||
LINES=`wc -l $TEMPFILE | awk '{ print $1; }'`
|
||||
if [ "$LINES" != "1" ]; then
|
||||
cat $TEMPFILE
|
||||
fi
|
||||
done
|
||||
done
|
||||
rm -f $TEMPFILE
|
||||
Reference in New Issue
Block a user