mirror of
https://github.com/tw93/Mole.git
synced 2026-02-15 08:10:09 +00:00
Fix use find (#399)
This commit is contained in:
@@ -411,21 +411,25 @@ scan_purge_targets() {
|
|||||||
|
|
||||||
if [[ "$use_find" == "true" ]]; then
|
if [[ "$use_find" == "true" ]]; then
|
||||||
# Pruned find avoids descending into heavy directories.
|
# Pruned find avoids descending into heavy directories.
|
||||||
local find_expr=()
|
|
||||||
local prune_dirs=(".git" "Library" ".Trash" "Applications")
|
local prune_dirs=(".git" "Library" ".Trash" "Applications")
|
||||||
for dir in "${prune_dirs[@]}"; do
|
local purge_targets=("${PURGE_TARGETS[@]}")
|
||||||
find_expr+=("-name" "$dir" "-prune" "-o")
|
|
||||||
|
local prune_expr=()
|
||||||
|
for i in "${!prune_dirs[@]}"; do
|
||||||
|
prune_expr+=( -name "${prune_dirs[$i]}" )
|
||||||
|
[[ $i -lt $((${#prune_dirs[@]} - 1)) ]] && prune_expr+=( -o )
|
||||||
done
|
done
|
||||||
local i=0
|
|
||||||
for target in "${PURGE_TARGETS[@]}"; do
|
local target_expr=()
|
||||||
find_expr+=("-name" "$target" "-print" "-prune")
|
for i in "${!purge_targets[@]}"; do
|
||||||
if [[ $i -lt $((${#PURGE_TARGETS[@]} - 1)) ]]; then
|
target_expr+=( -name "${purge_targets[$i]}" -print )
|
||||||
find_expr+=("-o")
|
[[ $i -lt $((${#purge_targets[@]} - 1)) ]] && target_expr+=( -o )
|
||||||
fi
|
|
||||||
((i++))
|
|
||||||
done
|
done
|
||||||
|
|
||||||
command find "$search_path" -mindepth "$min_depth" -maxdepth "$max_depth" -type d \
|
command find "$search_path" -mindepth "$min_depth" -maxdepth "$max_depth" -type d \
|
||||||
\( "${find_expr[@]}" \) 2> /dev/null > "$output_file.raw" || true
|
\( "${prune_expr[@]}" \) -prune -o \
|
||||||
|
\( "${target_expr[@]}" \) \
|
||||||
|
2>&1 | tee "$output_file.raw" > /dev/null
|
||||||
|
|
||||||
process_scan_results "$output_file.raw"
|
process_scan_results "$output_file.raw"
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user