plan9port/bin/g

43 lines
549 B
Text
Raw Permalink 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"
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]$'`
;;
*)
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