|
|
# 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 itself should be executable. |
if [[ $(command find "$0" -executable 2> /dev/null) ]]; then |
local testsubject="$(type -P find)" |
|
if [[ $(command find "$testsubject" -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 "$testsubject" -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 "$testsubject" -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}) |
|
|
# HACK: This is a rather noisy, but portable way to implement -quit | # HACK: This is a rather noisy, but portable way to implement -quit |
while read LIST; do | while read LIST; do |
break # Set LIST | break # Set LIST |
done < <(find $HOME/ /var/tmp/ /tmp/ -writable) |
done < <(find $HOME/ /var/tmp/ /tmp/ -writable -print) |
[[ $LIST ]] || | [[ $LIST ]] || |
die 1 "Unable to find a satisfactory location for temporary files" | die 1 "Unable to find a satisfactory location for temporary files" |
| |