refactor script
This commit is contained in:
@@ -89,8 +89,9 @@ ls_prune_bundle_id() {
|
|||||||
[[ -d "$root" ]] || continue
|
[[ -d "$root" ]] || continue
|
||||||
candidates+=$'\n'"$(/usr/bin/mdfind -onlyin "$root" "kMDItemCFBundleIdentifier == '${bundle_id}'" 2>/dev/null || true)"
|
candidates+=$'\n'"$(/usr/bin/mdfind -onlyin "$root" "kMDItemCFBundleIdentifier == '${bundle_id}'" 2>/dev/null || true)"
|
||||||
done
|
done
|
||||||
# Include backups adjacent to keep_path
|
# Include backups adjacent to keep_path (quote-safe)
|
||||||
candidates+=$'\n'$(/bin/ls -1d "${keep_path%/*.app}"/*.bak 2>/dev/null || true)
|
local parent_dir="${keep_path%/*.app}"
|
||||||
|
candidates+=$'\n'$(/bin/ls -1d "${parent_dir}/"*.bak 2>/dev/null || true)
|
||||||
local LSREG="/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister"
|
local LSREG="/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister"
|
||||||
printf "%s\n" "$candidates" | /usr/bin/awk 'NF' | /usr/bin/sort -u | while IFS= read -r p; do
|
printf "%s\n" "$candidates" | /usr/bin/awk 'NF' | /usr/bin/sort -u | while IFS= read -r p; do
|
||||||
[[ -z "$p" || ! -d "$p" || "$p" == "$keep_path" ]] && continue
|
[[ -z "$p" || ! -d "$p" || "$p" == "$keep_path" ]] && continue
|
||||||
@@ -131,9 +132,7 @@ unmount_existing_repertory_volumes() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# ----- user LaunchAgents (by LABEL_PREFIX only) -----
|
# ----- user LaunchAgents (by LABEL_PREFIX only) -----
|
||||||
get_plist_label() {
|
get_plist_label() { /usr/bin/defaults read "$1" Label 2>/dev/null || /usr/libexec/PlistBuddy -c "Print :Label" "$1" 2>/dev/null || basename "$1" .plist; }
|
||||||
/usr/bin/defaults read "$1" Label 2>/dev/null || /usr/libexec/PlistBuddy -c "Print :Label" "$1" 2>/dev/null || basename "$1" .plist
|
|
||||||
}
|
|
||||||
|
|
||||||
snapshot_launchagents_user() {
|
snapshot_launchagents_user() {
|
||||||
local user_agents="$HOME/Library/LaunchAgents"
|
local user_agents="$HOME/Library/LaunchAgents"
|
||||||
|
|||||||
Reference in New Issue
Block a user