shithub: riscv

ref: 1d83d2a74e54382ef9182ad7b136a676c6a8be1c
dir: /rc/bin/g/

View raw version
#!/bin/rc 

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 
         files=(`{ls *.[bcChm] *.cc *.py *.tex *.ms *.java >[2]/dev/null}) 
case * 
         pattern=$1 
         shift 
         files=($*) 
} 
grep -n $flags -- $pattern $files /dev/null