Make 'g' grep recursively by default.

This commit is contained in:
Ori Bernstein 2019-06-04 22:36:32 -07:00
parent 12e136332a
commit 033c2812c2
2 changed files with 25 additions and 14 deletions

View file

@ -1,7 +1,13 @@
#!/bin/rc
rfork e
nl='
'
flags=()
recurse=()
while(! ~ $#* 1 && ~ $1 -* && ! ~ $1 --){
if(~ $1 '-n')
recurse=-n1
if not
flags=($flags $1);
shift
}
@ -14,7 +20,7 @@ case 0
exit usage
case 1
pattern=$1
files=(`{ls *.[bcChlmsy] *.asm *.awk *.cc *.cgi *.cpp *.cs *.go *.goc *.java *.lx *.ms *.pl *.py *.rc *.tex *.xy >[2]/dev/null})
files=`$nl{walk -f $recurse | grep '\.([bcChlmsy]|asm|awk|cc|cgi|cpp|cs|go|goc|java|lx|ms|pl|py|rc|tex|xy)$' >[2]/dev/null}
case *
pattern=$1
shift

View file

@ -113,11 +113,16 @@ with
.B -n
(plus aditional flags, if provided)
and forces tagging of output lines by file name. If no files
are listed, it searches all files matching
are listed, it recursively searches the current directory for
all files matching
.B *.b *.c *.C *.h *.l *.m *.s *.y
.B *.asm *.cc *.cs *.lx *.cgi *.pl
.B *.py *.tex *.ms *.java *.xy *.go
.B *.goc *.cpp
.PP
The recursive search can be suppressed by passing g the
.B -n
flag.
.SH SOURCE
.B /sys/src/cmd/grep
.br