> I found your post a bit confusing then. The little bit of script you
> posted won't do the job, and the problem is not related to find at
> all,
>
> Anyway, while working with some hugely messy non-plan 9-software, I
> found I really needed grep -r.
>
> See /n/sources/contrib/rminnich/grep
why not just use a russ' g from p9p?
- erik
here's a variant:
#!/bin/rc
rfork e
filepat='\.h$'
exec g $*
of my version:
#!/bin/rc
rfork e
flags=-n
re=()
files=/dev/null
f=1
if(~ $#filepat 0)
filepat = '\.[Cbchlmsy]$'
fn collect{
find $* | grep $filepat
}
fn collect1{
ls | grep $filepat
}
for(i){
if(~ $f 1 && ~ $i -*)
flags = ($flags $i)
if not if (~ $#re 0){
f = 0
re = $i
}
if not{
if(test -d $i)
files = ($files `{collect $i})
if not
files = ($files $i)
}
}
if(~ $#re 0){
echo usage: g '[flags]' pattern ... >[1=2]
exit usage
}
modre>[2=]
switch($#files){
case 1
grep $flags $re `{collect1} $files
case *
grep $flags $re $files
}