2011-11-21 16:39:34 +00:00
|
|
|
#!/bin/rc
|
2016-03-13 21:34:08 +00:00
|
|
|
rfork e
|
2011-11-21 16:39:34 +00:00
|
|
|
flags=()
|
|
|
|
while(! ~ $#* 1 && ~ $1 -* && ! ~ $1 --){
|
|
|
|
flags=($flags $1);
|
|
|
|
shift
|
|
|
|
}
|
|
|
|
if(~ $1 --)
|
|
|
|
shift
|
|
|
|
|
|
|
|
switch($#*){
|
|
|
|
case 0
|
|
|
|
echo 'usage: g [flags] pattern [files]' >[1=2]
|
|
|
|
exit usage
|
|
|
|
case 1
|
|
|
|
pattern=$1
|
2015-03-09 01:46:00 +00:00
|
|
|
files=(`{ls *.[bcChlmsy] *.asm *.awk *.cc *.cgi *.cpp *.cs *.go *.goc *.java *.lx *.ms *.pl *.py *.rc *.tex *.xy >[2]/dev/null})
|
2011-11-21 16:39:34 +00:00
|
|
|
case *
|
|
|
|
pattern=$1
|
|
|
|
shift
|
|
|
|
files=($*)
|
|
|
|
}
|
|
|
|
grep -n $flags -- $pattern $files /dev/null
|