1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-12 07:38:59 +00:00

chore: auto format code

This commit is contained in:
Tw93
2026-02-10 07:07:52 +00:00
parent 172afa83af
commit 9aa5a0a69d
5 changed files with 370 additions and 370 deletions

View File

@@ -79,17 +79,17 @@ uninstall_resolve_display_name() {
if [[ -f "$app_path/Contents/Info.plist" ]]; then
local md_display_name
if [[ -n "$MOLE_UNINSTALL_USER_LC_ALL" ]]; then
md_display_name=$(run_with_timeout 0.04 env LC_ALL="$MOLE_UNINSTALL_USER_LC_ALL" LANG="$MOLE_UNINSTALL_USER_LANG" mdls -name kMDItemDisplayName -raw "$app_path" 2>/dev/null || echo "")
md_display_name=$(run_with_timeout 0.04 env LC_ALL="$MOLE_UNINSTALL_USER_LC_ALL" LANG="$MOLE_UNINSTALL_USER_LANG" mdls -name kMDItemDisplayName -raw "$app_path" 2> /dev/null || echo "")
elif [[ -n "$MOLE_UNINSTALL_USER_LANG" ]]; then
md_display_name=$(run_with_timeout 0.04 env LANG="$MOLE_UNINSTALL_USER_LANG" mdls -name kMDItemDisplayName -raw "$app_path" 2>/dev/null || echo "")
md_display_name=$(run_with_timeout 0.04 env LANG="$MOLE_UNINSTALL_USER_LANG" mdls -name kMDItemDisplayName -raw "$app_path" 2> /dev/null || echo "")
else
md_display_name=$(run_with_timeout 0.04 mdls -name kMDItemDisplayName -raw "$app_path" 2>/dev/null || echo "")
md_display_name=$(run_with_timeout 0.04 mdls -name kMDItemDisplayName -raw "$app_path" 2> /dev/null || echo "")
fi
local bundle_display_name
bundle_display_name=$(plutil -extract CFBundleDisplayName raw "$app_path/Contents/Info.plist" 2>/dev/null || echo "")
bundle_display_name=$(plutil -extract CFBundleDisplayName raw "$app_path/Contents/Info.plist" 2> /dev/null || echo "")
local bundle_name
bundle_name=$(plutil -extract CFBundleName raw "$app_path/Contents/Info.plist" 2>/dev/null || echo "")
bundle_name=$(plutil -extract CFBundleName raw "$app_path/Contents/Info.plist" 2> /dev/null || echo "")
if [[ "$md_display_name" == /* ]]; then
md_display_name=""
@@ -125,7 +125,7 @@ uninstall_acquire_metadata_lock() {
local lock_dir="$1"
local attempts=0
while ! mkdir "$lock_dir" 2>/dev/null; do
while ! mkdir "$lock_dir" 2> /dev/null; do
((attempts++))
if [[ $attempts -ge 40 ]]; then
return 1
@@ -140,12 +140,12 @@ uninstall_acquire_metadata_lock() {
local lock_age
lock_age=$(($(get_epoch_seconds) - lock_mtime))
if [[ "$lock_age" =~ ^-?[0-9]+$ && $lock_age -gt 300 ]]; then
rmdir "$lock_dir" 2>/dev/null || true
rmdir "$lock_dir" 2> /dev/null || true
fi
fi
fi
sleep 0.1 2>/dev/null || sleep 1
sleep 0.1 2> /dev/null || sleep 1
done
return 0
@@ -153,7 +153,7 @@ uninstall_acquire_metadata_lock() {
uninstall_release_metadata_lock() {
local lock_dir="$1"
[[ -d "$lock_dir" ]] && rmdir "$lock_dir" 2>/dev/null || true
[[ -d "$lock_dir" ]] && rmdir "$lock_dir" 2> /dev/null || true
}
uninstall_collect_inline_metadata() {
@@ -167,9 +167,9 @@ uninstall_collect_inline_metadata() {
local last_used_epoch=0
local metadata_date
metadata_date=$(run_with_timeout "$MOLE_UNINSTALL_INLINE_MDLS_TIMEOUT_SEC" mdls -name kMDItemLastUsedDate -raw "$app_path" 2>/dev/null || echo "")
metadata_date=$(run_with_timeout "$MOLE_UNINSTALL_INLINE_MDLS_TIMEOUT_SEC" mdls -name kMDItemLastUsedDate -raw "$app_path" 2> /dev/null || echo "")
if [[ "$metadata_date" != "(null)" && -n "$metadata_date" ]]; then
last_used_epoch=$(date -j -f "%Y-%m-%d %H:%M:%S %z" "$metadata_date" "+%s" 2>/dev/null || echo "0")
last_used_epoch=$(date -j -f "%Y-%m-%d %H:%M:%S %z" "$metadata_date" "+%s" 2> /dev/null || echo "0")
fi
# Fallback to app mtime so first scan does not show "...".
@@ -187,7 +187,7 @@ uninstall_collect_inline_metadata() {
start_uninstall_metadata_refresh() {
local refresh_file="$1"
[[ ! -s "$refresh_file" ]] && {
rm -f "$refresh_file" 2>/dev/null || true
rm -f "$refresh_file" 2> /dev/null || true
return 0
}
@@ -195,15 +195,15 @@ start_uninstall_metadata_refresh() {
_refresh_debug() {
if [[ "${MO_DEBUG:-}" == "1" ]]; then
local ts
ts=$(date "+%Y-%m-%d %H:%M:%S" 2>/dev/null || echo "?")
echo "[$ts] DEBUG: [metadata-refresh] $*" >>"${HOME}/.config/mole/mole_debug_session.log" 2>/dev/null || true
ts=$(date "+%Y-%m-%d %H:%M:%S" 2> /dev/null || echo "?")
echo "[$ts] DEBUG: [metadata-refresh] $*" >> "${HOME}/.config/mole/mole_debug_session.log" 2> /dev/null || true
fi
}
ensure_user_dir "$MOLE_UNINSTALL_META_CACHE_DIR"
ensure_user_file "$MOLE_UNINSTALL_META_CACHE_FILE"
if [[ ! -r "$MOLE_UNINSTALL_META_CACHE_FILE" ]]; then
if ! : >"$MOLE_UNINSTALL_META_CACHE_FILE" 2>/dev/null; then
if ! : > "$MOLE_UNINSTALL_META_CACHE_FILE" 2> /dev/null; then
_refresh_debug "Cannot create cache file, aborting"
exit 0
fi
@@ -214,7 +214,7 @@ start_uninstall_metadata_refresh() {
fi
local updates_file
updates_file=$(mktemp 2>/dev/null) || {
updates_file=$(mktemp 2> /dev/null) || {
_refresh_debug "mktemp failed, aborting"
exit 0
}
@@ -238,9 +238,9 @@ start_uninstall_metadata_refresh() {
(
local last_used_epoch=0
local metadata_date
metadata_date=$(run_with_timeout 0.2 mdls -name kMDItemLastUsedDate -raw "$app_path" 2>/dev/null || echo "")
metadata_date=$(run_with_timeout 0.2 mdls -name kMDItemLastUsedDate -raw "$app_path" 2> /dev/null || echo "")
if [[ "$metadata_date" != "(null)" && -n "$metadata_date" ]]; then
last_used_epoch=$(date -j -f "%Y-%m-%d %H:%M:%S %z" "$metadata_date" "+%s" 2>/dev/null || echo "0")
last_used_epoch=$(date -j -f "%Y-%m-%d %H:%M:%S %z" "$metadata_date" "+%s" 2> /dev/null || echo "0")
fi
if [[ ! "$last_used_epoch" =~ ^[0-9]+$ || $last_used_epoch -le 0 ]]; then
@@ -251,25 +251,25 @@ start_uninstall_metadata_refresh() {
size_kb=$(get_path_size_kb "$app_path")
[[ "$size_kb" =~ ^[0-9]+$ ]] || size_kb=0
printf "%s|%s|%s|%s|%s|%s|%s\n" "$app_path" "${app_mtime:-0}" "$size_kb" "${last_used_epoch:-0}" "$now_epoch" "$bundle_id" "$display_name" >"$worker_output"
printf "%s|%s|%s|%s|%s|%s|%s\n" "$app_path" "${app_mtime:-0}" "$size_kb" "${last_used_epoch:-0}" "$now_epoch" "$bundle_id" "$display_name" > "$worker_output"
) &
worker_pids+=($!)
if ((${#worker_pids[@]} >= max_parallel)); then
wait "${worker_pids[0]}" 2>/dev/null || true
wait "${worker_pids[0]}" 2> /dev/null || true
worker_pids=("${worker_pids[@]:1}")
fi
done <"$refresh_file"
done < "$refresh_file"
local worker_pid
for worker_pid in "${worker_pids[@]}"; do
wait "$worker_pid" 2>/dev/null || true
wait "$worker_pid" 2> /dev/null || true
done
local worker_output
for worker_output in "${updates_file}".*; do
[[ -f "$worker_output" ]] || continue
cat "$worker_output" >>"$updates_file"
cat "$worker_output" >> "$updates_file"
rm -f "$worker_output"
done
@@ -285,7 +285,7 @@ start_uninstall_metadata_refresh() {
fi
local merged_file
merged_file=$(mktemp 2>/dev/null) || {
merged_file=$(mktemp 2> /dev/null) || {
_refresh_debug "mktemp for merge failed, aborting"
uninstall_release_metadata_lock "$MOLE_UNINSTALL_META_CACHE_LOCK"
rm -f "$updates_file"
@@ -300,17 +300,17 @@ start_uninstall_metadata_refresh() {
print updates[path]
}
}
' "$updates_file" "$MOLE_UNINSTALL_META_CACHE_FILE" >"$merged_file"
' "$updates_file" "$MOLE_UNINSTALL_META_CACHE_FILE" > "$merged_file"
mv "$merged_file" "$MOLE_UNINSTALL_META_CACHE_FILE" 2>/dev/null || {
cp "$merged_file" "$MOLE_UNINSTALL_META_CACHE_FILE" 2>/dev/null || true
mv "$merged_file" "$MOLE_UNINSTALL_META_CACHE_FILE" 2> /dev/null || {
cp "$merged_file" "$MOLE_UNINSTALL_META_CACHE_FILE" 2> /dev/null || true
rm -f "$merged_file"
}
uninstall_release_metadata_lock "$MOLE_UNINSTALL_META_CACHE_LOCK"
rm -f "$updates_file"
rm -f "$refresh_file" 2>/dev/null || true
) >/dev/null 2>&1 &
rm -f "$refresh_file" 2> /dev/null || true
) > /dev/null 2>&1 &
}
@@ -322,9 +322,9 @@ scan_applications() {
merged_file="${temp_file}.merged"
refresh_file="${temp_file}.refresh"
cache_snapshot_file="${temp_file}.cache"
: >"$scan_raw_file"
: >"$refresh_file"
: >"$cache_snapshot_file"
: > "$scan_raw_file"
: > "$refresh_file"
: > "$cache_snapshot_file"
ensure_user_dir "$MOLE_UNINSTALL_META_CACHE_DIR"
ensure_user_file "$MOLE_UNINSTALL_META_CACHE_FILE"
@@ -332,7 +332,7 @@ scan_applications() {
local cache_source_is_temp=false
if [[ ! -r "$cache_source" ]]; then
cache_source=$(create_temp_file)
: >"$cache_source"
: > "$cache_source"
cache_source_is_temp=true
fi
@@ -348,7 +348,7 @@ scan_applications() {
cache_mtimes+=("${cache_mtime:-0}")
cache_bundle_ids+=("${cache_bundle:-}")
cache_display_names+=("${cache_display:-}")
done <"$cache_source"
done < "$cache_source"
lookup_cached_identity() {
local target_path="$1"
@@ -385,13 +385,13 @@ scan_applications() {
# shellcheck disable=SC2329 # Function invoked indirectly via trap
trap_scan_cleanup() {
if [[ -n "$spinner_pid" ]]; then
kill -TERM "$spinner_pid" 2>/dev/null || true
wait "$spinner_pid" 2>/dev/null || true
kill -TERM "$spinner_pid" 2> /dev/null || true
wait "$spinner_pid" 2> /dev/null || true
fi
if [[ -f "$spinner_shown_file" ]]; then
printf "\r\033[K" >&2
fi
rm -f "$temp_file" "$scan_raw_file" "$merged_file" "$refresh_file" "$cache_snapshot_file" "${temp_file}.sorted" "${temp_file}.progress" "$spinner_shown_file" 2>/dev/null || true
rm -f "$temp_file" "$scan_raw_file" "$merged_file" "$refresh_file" "$cache_snapshot_file" "${temp_file}.sorted" "${temp_file}.progress" "$spinner_shown_file" 2> /dev/null || true
exit 130
}
trap trap_scan_cleanup INT
@@ -440,18 +440,18 @@ scan_applications() {
if [[ -L "$app_path" ]]; then
local link_target
link_target=$(readlink "$app_path" 2>/dev/null)
link_target=$(readlink "$app_path" 2> /dev/null)
if [[ -n "$link_target" ]]; then
local resolved_target="$link_target"
if [[ "$link_target" != /* ]]; then
local link_dir
link_dir=$(dirname "$app_path")
resolved_target=$(cd "$link_dir" 2>/dev/null && cd "$(dirname "$link_target")" 2>/dev/null && pwd)/$(basename "$link_target") 2>/dev/null || echo ""
resolved_target=$(cd "$link_dir" 2> /dev/null && cd "$(dirname "$link_target")" 2> /dev/null && pwd)/$(basename "$link_target") 2> /dev/null || echo ""
fi
case "$resolved_target" in
/System/* | /usr/bin/* | /usr/lib/* | /bin/* | /sbin/* | /private/etc/*)
continue
;;
/System/* | /usr/bin/* | /usr/lib/* | /bin/* | /sbin/* | /private/etc/*)
continue
;;
esac
fi
fi
@@ -461,16 +461,16 @@ scan_applications() {
local cached_identity cached_bundle_id cached_display_name
cached_identity=$(lookup_cached_identity "$app_path" "$app_mtime")
IFS='|' read -r cached_bundle_id cached_display_name <<<"$cached_identity"
IFS='|' read -r cached_bundle_id cached_display_name <<< "$cached_identity"
# Store tuple for pass 2 (bundle + display resolution, then cache merge).
app_data_tuples+=("${app_path}|${app_name}|${app_mtime}|${cached_bundle_id}|${cached_display_name}")
done < <(command find "$app_dir" -name "*.app" -maxdepth 3 -print0 2>/dev/null)
done < <(command find "$app_dir" -name "*.app" -maxdepth 3 -print0 2> /dev/null)
done
if [[ ${#app_data_tuples[@]} -eq 0 ]]; then
rm -f "$temp_file" "$scan_raw_file" "$merged_file" "$refresh_file" "$cache_snapshot_file" "${temp_file}.sorted" "${temp_file}.progress" "$spinner_shown_file" 2>/dev/null || true
[[ $cache_source_is_temp == true ]] && rm -f "$cache_source" 2>/dev/null || true
rm -f "$temp_file" "$scan_raw_file" "$merged_file" "$refresh_file" "$cache_snapshot_file" "${temp_file}.sorted" "${temp_file}.progress" "$spinner_shown_file" 2> /dev/null || true
[[ $cache_source_is_temp == true ]] && rm -f "$cache_source" 2> /dev/null || true
restore_scan_int_trap
printf "\r\033[K" >&2
echo "No applications found to uninstall." >&2
@@ -492,13 +492,13 @@ scan_applications() {
local app_data_tuple="$1"
local output_file="$2"
IFS='|' read -r app_path app_name app_mtime cached_bundle_id cached_display_name <<<"$app_data_tuple"
IFS='|' read -r app_path app_name app_mtime cached_bundle_id cached_display_name <<< "$app_data_tuple"
local bundle_id="${cached_bundle_id:-}"
if [[ -z "$bundle_id" ]]; then
bundle_id="unknown"
if [[ -f "$app_path/Contents/Info.plist" ]]; then
bundle_id=$(defaults read "$app_path/Contents/Info.plist" CFBundleIdentifier 2>/dev/null || echo "unknown")
bundle_id=$(defaults read "$app_path/Contents/Info.plist" CFBundleIdentifier 2> /dev/null || echo "unknown")
fi
fi
@@ -515,27 +515,27 @@ scan_applications() {
display_name="${display_name//|/-}"
display_name="${display_name//[$'\t\r\n']/}"
echo "${app_path}|${display_name}|${bundle_id}|${app_mtime}" >>"$output_file"
echo "${app_path}|${display_name}|${bundle_id}|${app_mtime}" >> "$output_file"
}
local progress_file="${temp_file}.progress"
echo "0" >"$progress_file"
echo "0" > "$progress_file"
(
# shellcheck disable=SC2329 # Function invoked indirectly via trap
cleanup_spinner() { exit 0; }
trap cleanup_spinner TERM INT EXIT
sleep "$MOLE_UNINSTALL_SCAN_SPINNER_DELAY_SEC" 2>/dev/null || sleep 1
sleep "$MOLE_UNINSTALL_SCAN_SPINNER_DELAY_SEC" 2> /dev/null || sleep 1
[[ -f "$progress_file" ]] || exit 0
local spinner_chars="|/-\\"
local i=0
: >"$spinner_shown_file"
: > "$spinner_shown_file"
while true; do
local completed=$(cat "$progress_file" 2>/dev/null || echo 0)
local completed=$(cat "$progress_file" 2> /dev/null || echo 0)
local c="${spinner_chars:$((i % 4)):1}"
printf "\r\033[K%s Scanning applications... %d/%d" "$c" "$completed" "$total_apps" >&2
((i++))
sleep 0.1 2>/dev/null || sleep 1
sleep 0.1 2> /dev/null || sleep 1
done
) &
spinner_pid=$!
@@ -544,21 +544,21 @@ scan_applications() {
((app_count++))
process_app_metadata "$app_data_tuple" "$scan_raw_file" &
pids+=($!)
echo "$app_count" >"$progress_file"
echo "$app_count" > "$progress_file"
if ((${#pids[@]} >= max_parallel)); then
wait "${pids[0]}" 2>/dev/null
wait "${pids[0]}" 2> /dev/null
pids=("${pids[@]:1}")
fi
done
for pid in "${pids[@]}"; do
wait "$pid" 2>/dev/null
wait "$pid" 2> /dev/null
done
if [[ -n "$spinner_pid" ]]; then
kill -TERM "$spinner_pid" 2>/dev/null || true
wait "$spinner_pid" 2>/dev/null || true
kill -TERM "$spinner_pid" 2> /dev/null || true
wait "$spinner_pid" 2> /dev/null || true
fi
if [[ -f "$spinner_shown_file" ]]; then
echo -ne "\r\033[K" >&2
@@ -567,8 +567,8 @@ scan_applications() {
if [[ ! -s "$scan_raw_file" ]]; then
echo "No applications found to uninstall" >&2
rm -f "$temp_file" "$scan_raw_file" "$merged_file" "$refresh_file" "$cache_snapshot_file" "${temp_file}.sorted" "${temp_file}.progress" "$spinner_shown_file" 2>/dev/null || true
[[ $cache_source_is_temp == true ]] && rm -f "$cache_source" 2>/dev/null || true
rm -f "$temp_file" "$scan_raw_file" "$merged_file" "$refresh_file" "$cache_snapshot_file" "${temp_file}.sorted" "${temp_file}.progress" "$spinner_shown_file" 2> /dev/null || true
[[ $cache_source_is_temp == true ]] && rm -f "$cache_source" 2> /dev/null || true
restore_scan_int_trap
return 1
fi
@@ -590,9 +590,9 @@ scan_applications() {
{
print $0 "|" cache_mtime[$1] "|" cache_size[$1] "|" cache_epoch[$1] "|" cache_updated[$1] "|" cache_bundle[$1] "|" cache_display[$1]
}
' "$cache_source" "$scan_raw_file" >"$merged_file"
' "$cache_source" "$scan_raw_file" > "$merged_file"
if [[ ! -s "$merged_file" && -s "$scan_raw_file" ]]; then
awk '{print $0 "||||||"}' "$scan_raw_file" >"$merged_file"
awk '{print $0 "||||||"}' "$scan_raw_file" > "$merged_file"
fi
local current_epoch
@@ -644,7 +644,7 @@ scan_applications() {
if [[ $inline_metadata_count -lt $MOLE_UNINSTALL_INLINE_METADATA_LIMIT ]]; then
local inline_metadata inline_size_kb inline_epoch inline_updated_epoch
inline_metadata=$(uninstall_collect_inline_metadata "$app_path" "${app_mtime:-0}" "$current_epoch")
IFS='|' read -r inline_size_kb inline_epoch inline_updated_epoch <<<"$inline_metadata"
IFS='|' read -r inline_size_kb inline_epoch inline_updated_epoch <<< "$inline_metadata"
((inline_metadata_count++))
if [[ "$inline_size_kb" =~ ^[0-9]+$ && $inline_size_kb -gt 0 ]]; then
@@ -659,36 +659,36 @@ scan_applications() {
cached_updated_epoch="$inline_updated_epoch"
fi
fi
printf "%s|%s|%s|%s\n" "$app_path" "${app_mtime:-0}" "$bundle_id" "$display_name" >>"$refresh_file"
printf "%s|%s|%s|%s\n" "$app_path" "${app_mtime:-0}" "$bundle_id" "$display_name" >> "$refresh_file"
fi
local persist_updated_epoch=0
if [[ "$cached_updated_epoch" =~ ^[0-9]+$ && $cached_updated_epoch -gt 0 ]]; then
persist_updated_epoch="$cached_updated_epoch"
fi
printf "%s|%s|%s|%s|%s|%s|%s\n" "$app_path" "${app_mtime:-0}" "${final_size_kb:-0}" "${final_epoch:-0}" "${persist_updated_epoch:-0}" "$bundle_id" "$display_name" >>"$cache_snapshot_file"
printf "%s|%s|%s|%s|%s|%s|%s\n" "$app_path" "${app_mtime:-0}" "${final_size_kb:-0}" "${final_epoch:-0}" "${persist_updated_epoch:-0}" "$bundle_id" "$display_name" >> "$cache_snapshot_file"
echo "${final_epoch}|${app_path}|${display_name}|${bundle_id}|${final_size}|${final_last_used}|${final_size_kb}" >>"$temp_file"
done <"$merged_file"
echo "${final_epoch}|${app_path}|${display_name}|${bundle_id}|${final_size}|${final_last_used}|${final_size_kb}" >> "$temp_file"
done < "$merged_file"
if [[ -s "$cache_snapshot_file" ]]; then
if uninstall_acquire_metadata_lock "$MOLE_UNINSTALL_META_CACHE_LOCK"; then
mv "$cache_snapshot_file" "$MOLE_UNINSTALL_META_CACHE_FILE" 2>/dev/null || {
cp "$cache_snapshot_file" "$MOLE_UNINSTALL_META_CACHE_FILE" 2>/dev/null || true
mv "$cache_snapshot_file" "$MOLE_UNINSTALL_META_CACHE_FILE" 2> /dev/null || {
cp "$cache_snapshot_file" "$MOLE_UNINSTALL_META_CACHE_FILE" 2> /dev/null || true
rm -f "$cache_snapshot_file"
}
uninstall_release_metadata_lock "$MOLE_UNINSTALL_META_CACHE_LOCK"
fi
fi
sort -t'|' -k1,1n "$temp_file" >"${temp_file}.sorted" || {
sort -t'|' -k1,1n "$temp_file" > "${temp_file}.sorted" || {
rm -f "$temp_file" "$scan_raw_file" "$merged_file" "$refresh_file" "$cache_snapshot_file"
[[ $cache_source_is_temp == true ]] && rm -f "$cache_source" 2>/dev/null || true
[[ $cache_source_is_temp == true ]] && rm -f "$cache_source" 2> /dev/null || true
restore_scan_int_trap
return 1
}
rm -f "$temp_file" "$scan_raw_file" "$merged_file" "$cache_snapshot_file"
[[ $cache_source_is_temp == true ]] && rm -f "$cache_source" 2>/dev/null || true
[[ $cache_source_is_temp == true ]] && rm -f "$cache_source" 2> /dev/null || true
[[ $total_apps -gt 50 ]] && printf "\r\033[K" >&2
@@ -720,7 +720,7 @@ load_applications() {
apps_data+=("$epoch|$app_path|$app_name|$bundle_id|$size|$last_used|${size_kb:-0}")
selection_state+=(false)
done <"$apps_file"
done < "$apps_file"
if [[ ${#apps_data[@]} -eq 0 ]]; then
log_warning "No applications available for uninstallation"
@@ -737,8 +737,8 @@ cleanup() {
unset MOLE_ALT_SCREEN_ACTIVE
fi
if [[ -n "${sudo_keepalive_pid:-}" ]]; then
kill "$sudo_keepalive_pid" 2>/dev/null || true
wait "$sudo_keepalive_pid" 2>/dev/null || true
kill "$sudo_keepalive_pid" 2> /dev/null || true
wait "$sudo_keepalive_pid" 2> /dev/null || true
sudo_keepalive_pid=""
fi
# Log session end
@@ -757,13 +757,13 @@ main() {
# Global flags
for arg in "$@"; do
case "$arg" in
"--help" | "-h")
show_uninstall_help
exit 0
;;
"--debug")
export MO_DEBUG=1
;;
"--help" | "-h")
show_uninstall_help
exit 0
;;
"--debug")
export MO_DEBUG=1
;;
esac
done
@@ -815,7 +815,7 @@ main() {
local max_size_width=0
local max_last_width=0
for selected_app in "${selected_apps[@]}"; do
IFS='|' read -r _ _ app_name _ size last_used _ <<<"$selected_app"
IFS='|' read -r _ _ app_name _ size last_used _ <<< "$selected_app"
local name_width=$(get_display_width "$app_name")
[[ $name_width -gt $max_name_display_width ]] && max_name_display_width=$name_width
local size_display="$size"
@@ -829,7 +829,7 @@ main() {
((max_last_width < 5)) && max_last_width=5
((max_name_display_width < 16)) && max_name_display_width=16
local term_width=$(tput cols 2>/dev/null || echo 100)
local term_width=$(tput cols 2> /dev/null || echo 100)
local available_for_name=$((term_width - 17 - max_size_width - max_last_width))
local min_name_width=24
@@ -849,7 +849,7 @@ main() {
max_name_display_width=0
for selected_app in "${selected_apps[@]}"; do
IFS='|' read -r epoch app_path app_name bundle_id size last_used size_kb <<<"$selected_app"
IFS='|' read -r epoch app_path app_name bundle_id size last_used size_kb <<< "$selected_app"
local display_name
display_name=$(truncate_by_display_width "$app_name" "$name_trunc_limit")
@@ -874,7 +874,7 @@ main() {
local index=1
for row in "${summary_rows[@]}"; do
IFS='|' read -r name_cell size_cell last_cell <<<"$row"
IFS='|' read -r name_cell size_cell last_cell <<< "$row"
local name_display_width
name_display_width=$(get_display_width "$name_cell")
local name_char_count=${#name_cell}