plan9port/bin/g

43 lines
531 B
Text
Raw Normal View History

#!/bin/sh
2004-03-25 23:03:22 +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
;;
-*)
flags="$flags $1"
shift
;;
-)
inflags=no
shift
;;
*)
inflags=no
;;
esac
done
2004-03-25 23:03:22 +00:00
case $# in
0)
echo 1>&2 'usage: g [flags] pattern [files]'
2004-03-25 23:03:22 +00:00
exit 1
;;
1)
pattern="$1"
2005-11-28 16:36:57 +00:00
files=`/bin/ls *.[bcChlmy] *.cc *.cs *.lx *.cgi *.pl *.py *.tex *.ms *.java *.xy 2>/dev/null |
2005-08-31 03:56:35 +00:00
9 grep -v '\.tab?\.[ch]$'`
;;
*)
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