#!/bin/rc
rfork ne
mask=''
9fs idx
idx=/n/idx
base=/sys/src
while(! ~ $#* 0 && ~ $1 -* && ! ~ $1 - --){
switch($1){
case -[FfPcvgldsx]
mask=$mask^$1
case *
echo 'usage: srch [-FfPcvgldsx] <pattern>'
exit 'usage'
}
shift
}
if(~ $1 --)
shift
if (! ~ $mask '')
mask='^['^`{echo $mask | sed 's/-//g'}^'] [0-9]+ [0-9]+ .*'
grep $mask^$* $idx/symbs.idx |
while(txt=`{read}){
type=$txt(1)
fnum=$txt(2)
line=$txt(3)
file=`{grep '^'^$fnum^' ' $idx/files.idx}
match=`{echo $txt | sed 's/^[A-Za-z] [0-9]+ [0-9]+ //'}
echo $type $base/$file(2)^:$line $match
}
|