aboutsummaryrefslogtreecommitdiff
path: root/bin/g
blob: 33460f8b3d78d5074590da93c328c17d06c842a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/sh

inflags=yes
flags=""
while [ $# != 0 -a $inflags = yes ]
do
	case "$1" in
	--)
		inflags=no
		shift
		;;
	-*)
		flags="$flags $1"
		shift
		;;
	-)
		inflags=no
		shift
		;;
	*)
		inflags=no
		;;
	esac
done

case $# in
0)
	echo 1>&2 'usage: g [flags] pattern [files]'
	exit 1
	;;
1)
	pattern="$1"
	files=`/bin/ls *.[bcChlmy] *.cc *.lx *.py *.tex *.ms *.java *.xy 2>/dev/null |
		9 grep -v '\.tabx?\.[ch]$'`
	;;
*)
	pattern="$1"
	shift
	files="$@"
esac

exec 9 grep -n $flags -- "$pattern" $files /dev/null