#!/bin/rc

if(~ $#* 0){
	echo usage: g [grep opts] pattern
	exit 'usage'
}

# bugs in windoes rc(1) mean 'while(match=`{read})' fails with read
# dieing in pread() - not debugged yet. The strange thing is 'ls | read'
# works fine so its not pread() reading from a pipe thats the problem.
#
#du -a |
#	grep '\.h$|\.c$|\.C$|\.c++$|\.C++$|\.cpp$|\.hpp$|\.H$|\.h++$|\.s++$|\.S++$' |
#	while(match=`{read})
#		grep -n $* $match(2) /dev/null

du -a |
	grep '\.h$|\.c$|\.C$|\.c++$|\.C++$|\.cpp$|\.hpp$|\.H$|\.h++$\.s++$|\.S++$' |
	awk '-vpat='^$"* '{ system(sprintf("grep -n %s %s nul:", pat, $2)) }'

