Index: contrib/client-side/wcgrep
===================================================================
--- contrib/client-side/wcgrep	(revisione 27420)
+++ contrib/client-side/wcgrep	(copia locale)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 
 # Copyright 2004 Ben Reser <ben@reser.org>
 # Licensed under the terms subversion ships under or GPLv2.
@@ -27,33 +27,28 @@
 #                  If unset or null it defaults to -HnI (always print file
 #                  names, line numbers and ignore binary files).  If you wish
 #                  to set no default args set the variable to a space (" ").
-# WCGREP_IGNORE    Controls what files are ignored by the grep command.
-#                  This is a regex that is passed to the find command with
-#                  -regex so see find's man page for details.  If unset or
-#                  null defaults to '.*~$\|.*/\.svn\(/\|$\)', which will
-#                  ignore vim backup files and subversion admin dirs.
+# WCGREP_IGNORE    Controls what files are ignored by the search.  If unset
+#                  or null, grep is run on all files under version control.
 
+grep=${WCGREP_GREP:-'grep'}
+grepargs=${WCGREP_GREPARGS:-'-HnI'}
+grepignore=${WCGREP_IGNORE:-'^$'}
 
-arg_count=$#
-for (( i=1; i <= $arg_count; i++ )); do
-    arg="$1"
-    shift 1
-    if [ -z "$pattern" ]; then
-        if [ "$arg" == "--" ]; then
-            grepargs="$grepargs $arg"
-            pattern="$1"
-            shift 1
-            ((i++))
-        elif [ "${arg:0:1}" != "-" ]; then
-            pattern="$arg"
-        else
-            grepargs="$grepargs $arg"
-        fi  
-    else
-        pathargs="$pathargs $arg"
-    fi
+while [ $# -gt 0 ] && [ -z "$pattern" ]; do
+    case "$1" in
+        --) pattern=$2; shift ;;
+        -*) grepargs="$grepargs $arg" ;;
+        *)  pattern=$1 ;;
+    esac
+    shift
 done
 
-find $pathargs -regex ${WCGREP_IGNORE:-'.*~$\|.*/\.svn\(/\|$\)'} -prune -o \
-    -type f -print0 | xargs -r0 ${WCGREP_GREP:-grep} ${WCGREP_GREPARGS:--HnI} \
-    $grepargs "$pattern"
+if [ -z "$pattern" ]; then
+    echo >&2 "Usage: $0 [grep_args] {pattern} [file...]"
+    exit 1
+fi
+
+svn status -v "$@" | grep -v '^\?' | cut -c41- | $grep -v -- "$grepignore" |
+while read line; do
+    test -f "$line" && echo "$line"
+done | xargs $grep $grepargs -- "$pattern"


