View | Details | Raw Unified
Collapse All | Expand All

(-) revdep-rebuild-rewrite_pre7~ (-11 / +6 lines)
 Lines 100-129    Link Here 
# of various versions of -perm /+ blah blah and hacks
# of various versions of -perm /+ blah blah and hacks
find() {
find() {
	hash find || { die 1 'find not found!'; }
	hash find || { die 1 'find not found!'; }
	# We can be pretty sure "$0" should be executable.
	# We can be pretty sure find should be executable.
	if [[ $(command find "$0" -executable 2> /dev/null) ]]; then
	if [[ $(command find "$(type -P find)" -executable 2> /dev/null) ]]; then
		unset -f find # We can just use the command find
		unset -f find # We can just use the command find
	elif [[ $(command find "$0" -perm /u+x 2> /dev/null) ]]; then
	elif [[ $(command find "$(type -P find)" -perm /u+x 2> /dev/null) ]]; then
		find() {
		find() {
			a=(${@//-executable/-perm \/u+x})
			a=(${@//-executable/-perm \/u+x})
			a=(${a[@]//-writable/-perm \/u+w})
			a=(${a[@]//-writable/-perm \/u+w})
			a=(${a[@]//-readable/-perm \/r+w})
			a=(${a[@]//-readable/-perm \/r+w})
			command find "${a[@]}"
			command find "${a[@]}"
		}
		}
	elif [[ $(command find "$0" -perm +u+x 2> /dev/null) ]]; then
	elif [[ $(command find "$(type -P find)" -perm +u+x 2> /dev/null) ]]; then
		find() {
		find() {
			a=(${@//-executable/-perm +u+x})
			a=(${@//-executable/-perm +u+x})
			a=(${a[@]//-writable/-perm +u+w})
			a=(${a[@]//-writable/-perm +u+w})
			a=(${a[@]//-readable/-perm +r+w})
			a=(${a[@]//-readable/-perm +r+w})
			command find "${a[@]}"
			command find "${a[@]}"
		}
		}
	else # Last resort
	else
		find() {
		die 1 "don't know how to search for permissions with find"
			a=(${@//-executable/-exec test -x '{}' \;})
			a=(${a[@]//-writable/-exec test -w '{}' \;})
			a=(${a[@]//-readable/-exec test -r '{}' \;})
			command find "${a[@]}"
		}
	fi
	fi
	find "$@"
	find "$@"
}
}