Lines 100-129
Link Here
|
100 |
# of various versions of -perm /+ blah blah and hacks |
100 |
# of various versions of -perm /+ blah blah and hacks |
101 |
find() { |
101 |
find() { |
102 |
hash find || { die 1 'find not found!'; } |
102 |
hash find || { die 1 'find not found!'; } |
103 |
# We can be pretty sure "$0" should be executable. |
103 |
# We can be pretty sure find should be executable. |
104 |
if [[ $(command find "$0" -executable 2> /dev/null) ]]; then |
104 |
if [[ $(command find "$(type -P find)" -executable 2> /dev/null) ]]; then |
105 |
unset -f find # We can just use the command find |
105 |
unset -f find # We can just use the command find |
106 |
elif [[ $(command find "$0" -perm /u+x 2> /dev/null) ]]; then |
106 |
elif [[ $(command find "$(type -P find)" -perm /u+x 2> /dev/null) ]]; then |
107 |
find() { |
107 |
find() { |
108 |
a=(${@//-executable/-perm \/u+x}) |
108 |
a=(${@//-executable/-perm \/u+x}) |
109 |
a=(${a[@]//-writable/-perm \/u+w}) |
109 |
a=(${a[@]//-writable/-perm \/u+w}) |
110 |
a=(${a[@]//-readable/-perm \/r+w}) |
110 |
a=(${a[@]//-readable/-perm \/r+w}) |
111 |
command find "${a[@]}" |
111 |
command find "${a[@]}" |
112 |
} |
112 |
} |
113 |
elif [[ $(command find "$0" -perm +u+x 2> /dev/null) ]]; then |
113 |
elif [[ $(command find "$(type -P find)" -perm +u+x 2> /dev/null) ]]; then |
114 |
find() { |
114 |
find() { |
115 |
a=(${@//-executable/-perm +u+x}) |
115 |
a=(${@//-executable/-perm +u+x}) |
116 |
a=(${a[@]//-writable/-perm +u+w}) |
116 |
a=(${a[@]//-writable/-perm +u+w}) |
117 |
a=(${a[@]//-readable/-perm +r+w}) |
117 |
a=(${a[@]//-readable/-perm +r+w}) |
118 |
command find "${a[@]}" |
118 |
command find "${a[@]}" |
119 |
} |
119 |
} |
120 |
else # Last resort |
120 |
else |
121 |
find() { |
121 |
die 1 "don't know how to search for permissions with find" |
122 |
a=(${@//-executable/-exec test -x '{}' \;}) |
|
|
123 |
a=(${a[@]//-writable/-exec test -w '{}' \;}) |
124 |
a=(${a[@]//-readable/-exec test -r '{}' \;}) |
125 |
command find "${a[@]}" |
126 |
} |
127 |
fi |
122 |
fi |
128 |
find "$@" |
123 |
find "$@" |
129 |
} |
124 |
} |