changelog shortlog tags branches changeset files revisions annotate raw help

Mercurial > hg > plan9front / rc/bin/g

changeset 7261: 5151baad508e
parent: 16895cffe792
author: Ori Bernstein <ori@eigenstate.org>
date: Tue, 04 Jun 2019 22:47:07 -0700
permissions: -rwxr-xr-x
description: Remove trailing whitespace.
1 #!/bin/rc
2 rfork e
3 nl='
4 '
5 flags=()
6 recurse=()
7 while(! ~ $#* 1 && ~ $1 -* && ! ~ $1 --){
8  if(~ $1 '-n')
9  recurse=-n1
10  if not
11  flags=($flags $1);
12  shift
13 }
14 if(~ $1 --)
15  shift
16 
17 switch($#*){
18 case 0
19  echo 'usage: g [flags] pattern [files]' >[1=2]
20  exit usage
21 case 1
22  pattern=$1
23  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}
24 case *
25  pattern=$1
26  shift
27  files=($*)
28 }
29 grep -n $flags -- $pattern $files /dev/null