Only call find on directories.
This commit is contained in:
parent
2bd0b6ee61
commit
571208c8ee
@ -111,27 +111,34 @@ module Cask
|
|||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
for path in "${@}"; do
|
for path in "${@}"; do
|
||||||
if [[ ! -e "${path}" ]]; then
|
symlink=true
|
||||||
continue
|
[[ -L "${path}" ]] || symlink=false
|
||||||
fi
|
|
||||||
|
directory=false
|
||||||
|
if [[ -d "${path}" ]]; then
|
||||||
|
directory=true
|
||||||
|
|
||||||
if [[ -e "${path}/.DS_Store" ]]; then
|
if [[ -e "${path}/.DS_Store" ]]; then
|
||||||
/bin/rm -f "${path}/.DS_Store"
|
/bin/rm -- "${path}/.DS_Store"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Some packages leave broken symlinks around; we clean them out before
|
# Some packages leave broken symlinks around; we clean them out before
|
||||||
# attempting to `rmdir` to prevent extra cruft from accumulating.
|
# attempting to `rmdir` to prevent extra cruft from accumulating.
|
||||||
/usr/bin/find "${path}" -mindepth 1 -maxdepth 1 -type l ! -exec /bin/test -e {} \; -delete
|
/usr/bin/find -f "${path}" -- -mindepth 1 -maxdepth 1 -type l ! -exec /bin/test -e {} \; -delete
|
||||||
|
elif ! ${symlink} && [[ ! -e "${path}" ]]; then
|
||||||
|
# Skip paths that don't exists and aren't a broken symlink.
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ -L "${path}" ]]; then
|
if ${symlink}; then
|
||||||
# Delete directory symlink.
|
# Delete directory symlink.
|
||||||
/bin/rm "${path}"
|
/bin/rm -- "${path}"
|
||||||
elif [[ -d "${path}" ]]; then
|
elif ${directory}; then
|
||||||
# Delete directory if empty.
|
# Delete directory if empty.
|
||||||
/usr/bin/find "${path}" -maxdepth 0 -type d -empty -exec /bin/rmdir {} \;
|
/usr/bin/find -f "${path}" -- -maxdepth 0 -type d -empty -exec /bin/rmdir -- {} \;
|
||||||
else
|
else
|
||||||
# Try `rmdir` anyways to show a proper error.
|
# Try `rmdir` anyways to show a proper error.
|
||||||
/bin/rmdir "${path}"
|
/bin/rmdir -- "${path}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
BASH
|
BASH
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user