From faf29b05f163a2fd7aeb342a99fb27d57028ec85 Mon Sep 17 00:00:00 2001 From: Tw93 Date: Sat, 7 Mar 2026 20:30:06 +0800 Subject: [PATCH] Fix perl timeout fallback selection --- lib/core/timeout.sh | 4 ++-- tests/clean_system_caches.bats | 1 + tests/regression.bats | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/core/timeout.sh b/lib/core/timeout.sh index bcb3c9d..edd7051 100644 --- a/lib/core/timeout.sh +++ b/lib/core/timeout.sh @@ -42,9 +42,9 @@ if [[ -z "${MO_TIMEOUT_INITIALIZED:-}" ]]; then fi done - if [[ -z "$MO_TIMEOUT_BIN" ]] && command -v perl > /dev/null 2>&1; then + if command -v perl > /dev/null 2>&1; then MO_TIMEOUT_PERL_BIN="$(command -v perl)" - if [[ "${MO_DEBUG:-0}" == "1" ]]; then + if [[ -z "$MO_TIMEOUT_BIN" ]] && [[ "${MO_DEBUG:-0}" == "1" ]]; then echo "[TIMEOUT] Using perl fallback: $MO_TIMEOUT_PERL_BIN" >&2 fi fi diff --git a/tests/clean_system_caches.bats b/tests/clean_system_caches.bats index 9ab37fa..0275c70 100644 --- a/tests/clean_system_caches.bats +++ b/tests/clean_system_caches.bats @@ -252,6 +252,7 @@ set -euo pipefail source "$PROJECT_ROOT/lib/core/common.sh" source "$PROJECT_ROOT/lib/clean/caches.sh" MO_TIMEOUT_BIN="" +MO_TIMEOUT_PERL_BIN="${MO_TIMEOUT_PERL_BIN:-$(command -v perl)}" export MOLE_PROJECT_CACHE_DISCOVERY_TIMEOUT=0.5 export MOLE_PROJECT_CACHE_SCAN_TIMEOUT=0.5 SECONDS=0 diff --git a/tests/regression.bats b/tests/regression.bats index 202c0d3..3e10baa 100644 --- a/tests/regression.bats +++ b/tests/regression.bats @@ -114,6 +114,7 @@ EOF set -euo pipefail source "$PROJECT_ROOT/lib/core/timeout.sh" MO_TIMEOUT_BIN="" +MO_TIMEOUT_PERL_BIN="${MO_TIMEOUT_PERL_BIN:-$(command -v perl)}" SECONDS=0 set +e run_with_timeout 1 "$FAKE_CMD"