2005-01-11 17:49:03 +00:00
|
|
|
#!/bin/sh
|
2004-03-25 23:03:22 +00:00
|
|
|
|
2005-01-11 17:49:03 +00:00
|
|
|
inflags=yes
|
|
|
|
flags=""
|
|
|
|
while [ $# != 0 -a $inflags = yes ]
|
|
|
|
do
|
|
|
|
case "$1" in
|
2005-03-18 18:51:02 +00:00
|
|
|
--)
|
|
|
|
inflags=no
|
|
|
|
shift
|
|
|
|
;;
|
2005-01-11 17:49:03 +00:00
|
|
|
-*)
|
|
|
|
flags="$flags $1"
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
-)
|
|
|
|
inflags=no
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
inflags=no
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
2004-03-25 23:03:22 +00:00
|
|
|
|
2005-01-11 17:49:03 +00:00
|
|
|
case $# in
|
|
|
|
0)
|
|
|
|
echo 1>&2 'usage: g [flags] pattern [files]'
|
2004-03-25 23:03:22 +00:00
|
|
|
exit 1
|
2005-01-11 17:49:03 +00:00
|
|
|
;;
|
|
|
|
1)
|
|
|
|
pattern="$1"
|
2014-08-06 12:36:38 +00:00
|
|
|
files=`/bin/ls *.[bcChlmsy] *.asm *.cc *.cs *.lx *.cgi *.pl *.py *.tex *.ms *.java *.xy *.go *.goc 2>/dev/null |
|
2005-08-31 03:56:35 +00:00
|
|
|
9 grep -v '\.tab?\.[ch]$'`
|
2005-01-11 17:49:03 +00:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
pattern="$1"
|
|
|
|
shift
|
|
|
|
files="$@"
|
|
|
|
esac
|
2004-03-25 23:03:22 +00:00
|
|
|
|
2005-01-13 04:49:19 +00:00
|
|
|
exec 9 grep -n $flags -- "$pattern" $files /dev/null
|