1
0
mirror of https://github.com/tw93/Mole.git synced 2026-03-22 19:40:07 +00:00

refactor: Update shell arithmetic increment syntax from ((var++)) || true to var=$((var + 1)) across various scripts.

This commit is contained in:
tw93
2026-02-28 11:10:18 +08:00
parent 7d70889ad4
commit c19a0276b8
22 changed files with 141 additions and 141 deletions

View File

@@ -878,18 +878,18 @@ validate_terminal_environment() {
# Check if TERM is set
if [[ -z "${TERM:-}" ]]; then
log_warning "TERM environment variable not set"
((warnings++)) || true
warnings=$((warnings + 1))
fi
# Check if running in a known problematic terminal
case "${TERM:-}" in
dumb)
log_warning "Running in 'dumb' terminal, limited functionality"
((warnings++)) || true
warnings=$((warnings + 1))
;;
unknown)
log_warning "Terminal type unknown, may have display issues"
((warnings++)) || true
warnings=$((warnings + 1))
;;
esac
@@ -898,7 +898,7 @@ validate_terminal_environment() {
local cols=$(tput cols 2> /dev/null || echo "80")
if [[ "$cols" -lt 60 ]]; then
log_warning "Terminal width, $cols cols, is narrow, output may wrap"
((warnings++)) || true
warnings=$((warnings + 1))
fi
fi

View File

@@ -163,7 +163,7 @@ remove_apps_from_dock() {
local url
url=$(/usr/libexec/PlistBuddy -c "Print :persistent-apps:$i:tile-data:file-data:_CFURLString" "$plist" 2> /dev/null || echo "")
[[ -z "$url" ]] && {
((i++)) || true
i=$((i + 1))
continue
}
@@ -175,7 +175,7 @@ remove_apps_from_dock() {
continue
fi
fi
((i++)) || true
i=$((i + 1))
done
done

View File

@@ -536,7 +536,7 @@ calculate_total_size() {
if [[ -n "$file" && -e "$file" ]]; then
local size_kb
size_kb=$(get_path_size_kb "$file")
((total_kb += size_kb)) || true
total_kb=$((total_kb + size_kb))
fi
done <<< "$files"

View File

@@ -76,7 +76,7 @@ _request_password() {
if [[ -z "$password" ]]; then
unset password
((attempts++)) || true
attempts=$((attempts + 1))
if [[ $attempts -lt 3 ]]; then
echo -e "${GRAY}${ICON_WARNING}${NC} Password cannot be empty" > "$tty_path"
fi
@@ -91,7 +91,7 @@ _request_password() {
fi
unset password
((attempts++)) || true
attempts=$((attempts + 1))
if [[ $attempts -lt 3 ]]; then
echo -e "${GRAY}${ICON_WARNING}${NC} Incorrect password, try again" > "$tty_path"
fi
@@ -166,7 +166,7 @@ request_sudo_access() {
break
fi
sleep 0.1
((elapsed++)) || true
elapsed=$((elapsed + 1))
done
# Touch ID failed/cancelled - clean up thoroughly before password input
@@ -216,7 +216,7 @@ _start_sudo_keepalive() {
local retry_count=0
while true; do
if ! sudo -n -v 2> /dev/null; then
((retry_count++)) || true
retry_count=$((retry_count + 1))
if [[ $retry_count -ge 3 ]]; then
exit 1
fi

View File

@@ -138,8 +138,8 @@ truncate_by_display_width() {
fi
truncated+="$char"
((width += char_width)) || true
((i++)) || true
width=$((width + char_width))
i=$((i + 1))
done
# Restore locale
@@ -265,7 +265,7 @@ read_key() {
drain_pending_input() {
local drained=0
while IFS= read -r -s -n 1 -t 0.01 _ 2> /dev/null; do
((drained++)) || true
drained=$((drained + 1))
[[ $drained -gt 100 ]] && break
done
}
@@ -341,7 +341,7 @@ start_inline_spinner() {
local c="${chars:$((i % ${#chars})):1}"
# Output to stderr to avoid interfering with stdout
printf "\r${MOLE_SPINNER_PREFIX:-}${BLUE}%s${NC} %s" "$c" "$display_message" >&2 || break
((i++)) || true
i=$((i + 1))
sleep 0.05
done
@@ -367,7 +367,7 @@ stop_inline_spinner() {
local wait_count=0
while kill -0 "$INLINE_SPINNER_PID" 2> /dev/null && [[ $wait_count -lt 5 ]]; do
sleep 0.05 2> /dev/null || true
((wait_count++)) || true
wait_count=$((wait_count + 1))
done
# Only use SIGKILL as last resort if process is stuck