aboutsummaryrefslogtreecommitdiff
path: root/bin/g
blob: c9e8b92976d5c82247fa4c0918cda240a2262595 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/local/plan9/bin/rc

flags=()
while(! ~ $#* 1 && ~ $1 -*){
	flags=($flags $1)
	shift
}

switch($#*){
case 0
	echo 'usage: g [flags] pattern [files]' >[1=2]
	exit 1
case 1
	9grep -n $flags -- $1 *.[Cbchm] *.cc *.py *.tex *.ms *.java /dev/null \
	  |[2] {9grep -v '^(grep: can''t open \*|grep: \*\.)' >[1=2]; status=0}
case *
	9grep -n $flags -- $* /dev/null
}