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
|
|
|
|
-*)
|
|
|
|
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"
|
|
|
|
files=`/bin/ls *.[bcChm] *.cc *.py *.tex *.ms *.java 2>/dev/null`
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
pattern="$1"
|
|
|
|
shift
|
|
|
|
files="$@"
|
|
|
|
esac
|
2004-03-25 23:03:22 +00:00
|
|
|
|
2005-01-11 17:49:03 +00:00
|
|
|
exec grep -n $flags -- "$pattern" $files /dev/null
|