diff options
author | rsc <devnull@localhost> | 2005-01-11 17:49:03 +0000 |
---|---|---|
committer | rsc <devnull@localhost> | 2005-01-11 17:49:03 +0000 |
commit | 2c500adda28bdf7187de272a50fc1f37fe467160 (patch) | |
tree | 9da3b42fa5431d7b504d6eb5a440ec5399a37ab3 /bin/g | |
parent | b8f742db850ffc99333a97ab54fc820c6de0fd98 (diff) | |
download | plan9port-2c500adda28bdf7187de272a50fc1f37fe467160.tar.gz plan9port-2c500adda28bdf7187de272a50fc1f37fe467160.tar.bz2 plan9port-2c500adda28bdf7187de272a50fc1f37fe467160.zip |
remove references to hardcoded /usr/local/plan9 where possible
Diffstat (limited to 'bin/g')
-rwxr-xr-x | bin/g | 48 |
1 files changed, 33 insertions, 15 deletions
@@ -1,19 +1,37 @@ -#!/usr/local/plan9/bin/rc +#!/bin/sh -flags=() -while(! ~ $#* 1 && ~ $1 -*){ - flags=($flags $1) - shift -} +inflags=yes +flags="" +while [ $# != 0 -a $inflags = yes ] +do + case "$1" in + -*) + flags="$flags $1" + shift + ;; + -) + inflags=no + shift + ;; + *) + inflags=no + ;; + esac +done -switch($#*){ -case 0 - echo 'usage: g [flags] pattern [files]' >[1=2] +case $# in +0) + echo 1>&2 'usage: g [flags] pattern [files]' exit 1 -case 1 - 9grep -n $flags -- $1 *.[Cbchm] *.cc *.py *.tex *.ms *.java /dev/null \ - |[2] {9grep -v '^(grep: can''t open \*|grep: \*\.)' >[1=2]; status=0} -case * - 9grep -n $flags -- $* /dev/null -} + ;; +1) + pattern="$1" + files=`/bin/ls *.[bcChm] *.cc *.py *.tex *.ms *.java 2>/dev/null` + ;; +*) + pattern="$1" + shift + files="$@" +esac +exec grep -n $flags -- "$pattern" $files /dev/null |