nice fixups for file lists.
[feisty_meow.git] / scripts / buildor / search_code.sh
1 #!/bin/bash
2 seek="$1"; shift
3 if [ -z "$seek" ]; then
4   echo This script needs a pattern to look for in the current directory.
5   echo All code files here and in subdirectories will be searched for the
6   echo pattern.
7   exit 1
8 fi
9 #hmmm: might be nice to support multiple directories...
10 #      just need to pass them to find as an array maybe?
11 dir="$1"; shift
12 if [ -z "$dir" ]; then
13   dir=.
14 fi
15
16 #hmmm: we need to encode this useful logic as a list of binary file endings.
17 find "$dir" -type f \( -iname "*" \
18   ! -iname "*.bz2" \
19   ! -iname "*.class" \
20   ! -iname "*.dll" \
21   ! -iname "*.deb" \
22   ! -iname "*.dmg" \
23   ! -iname "*.exe" \
24   ! -iname "entries" \
25   ! -iname "*.git" \
26   ! -iname "*.gz" \
27   ! -iname "*.iar" \
28   ! -iname "*.jar" \
29   ! -iname "*.lib" \
30   ! -iname "*.oar" \
31   ! -iname "*.obj" \
32   ! -iname "*.png" \
33   ! -iname "*.snarf" \
34   ! -iname "*.svn" \
35   ! -iname "*.svn-base" \
36   ! -iname "*.tar" \
37   ! -iname "*.tmp" \
38   ! -iname "*.zip" \) \
39   -exec echo "\"{}\"" ';' | xargs grep -li "$seek" | grep -v "^\.[^\/]\|\/\."
40
41