diff --git a/scripts/xfind.sh b/scripts/xfind.sh index 5559fd69b..9fd2bfd25 100644 --- a/scripts/xfind.sh +++ b/scripts/xfind.sh @@ -2,26 +2,11 @@ # Subversion has really big ".svn" subdirs. This has much better performance # than the "find ... ! -path '*/.svn*' ! -path '*/CVS*' ..." used earlier -# in various places. +# in various places. Never use this with -depth! Instead pipe the output thru +# "tac" or "sort -r". -tmp1=`mktemp` tmp2=`mktemp` - -while [ "$#" -gt 0 ] -do - [ -z "${1##[-(\!]*}" ] && break - echo $1 >> $tmp1 - shift -done - -while ! cmp -s $tmp1 $tmp2 -do - cat $tmp1 > $tmp2 - find $( cat $tmp2 ) -maxdepth 1 -type d \ - ! -name 'CVS' ! -name '.svn' | sort -u > $tmp1 -done - -find $( cat $tmp2 ) -mindepth 1 -maxdepth 1 \ - ! -name 'CVS' ! -name '.svn' "$@" - -rm -f $tmp1 $tmp2 +dirs=""; while [ -n "${1##[-\(]*}" ]; do dirs="$dirs $1"; shift; done +if [ $# -eq 0 ]; then set -- -print; fi; +action=") -print"; if [ "${*#-print}" != "$*" ]; then action=""; fi +find $dirs '(' -path '*/.svn' -o -path '*/CVS' ')' -prune -o ${action:+\(} "$@" $action