mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-12 11:10:07 +00:00
42 lines
542 B
Bash
Executable file
42 lines
542 B
Bash
Executable file
#!/bin/sh
|
|
|
|
inflags=yes
|
|
flags=""
|
|
while [ $# != 0 -a $inflags = yes ]
|
|
do
|
|
case "$1" in
|
|
--)
|
|
inflags=no
|
|
shift
|
|
;;
|
|
-*)
|
|
flags="$flags $1"
|
|
shift
|
|
;;
|
|
-)
|
|
inflags=no
|
|
shift
|
|
;;
|
|
*)
|
|
inflags=no
|
|
;;
|
|
esac
|
|
done
|
|
|
|
case $# in
|
|
0)
|
|
echo 1>&2 'usage: g [flags] pattern [files]'
|
|
exit 1
|
|
;;
|
|
1)
|
|
pattern="$1"
|
|
files=`/bin/ls *.[bcChlmy] *.asm *.cc *.cs *.lx *.cgi *.pl *.py *.tex *.ms *.java *.xy *.go 2>/dev/null |
|
|
9 grep -v '\.tab?\.[ch]$'`
|
|
;;
|
|
*)
|
|
pattern="$1"
|
|
shift
|
|
files="$@"
|
|
esac
|
|
|
|
exec 9 grep -n $flags -- "$pattern" $files /dev/null
|