From a3cf3e7bae3d4c1d4c21d108abcfdaafa643e76c Mon Sep 17 00:00:00 2001 From: Sheldon Finlay Date: Fri, 27 Mar 2026 12:24:53 -0400 Subject: [PATCH] fix: add macOS timeout compatibility (gtimeout or perl fallback) --- loop.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/loop.sh b/loop.sh index 744e11e..771b9a5 100755 --- a/loop.sh +++ b/loop.sh @@ -81,6 +81,23 @@ if ! command -v jq &>/dev/null && ! command -v python3 &>/dev/null; then exit 1 fi +# --- macOS timeout compatibility --- +# macOS doesn't have GNU timeout. Use gtimeout (from coreutils) or a perl fallback. +if ! command -v timeout &>/dev/null; then + if command -v gtimeout &>/dev/null; then + timeout() { gtimeout "$@"; } + else + # Perl-based fallback: runs command with alarm signal + timeout() { + local duration="$1"; shift + perl -e ' + alarm shift @ARGV; + exec @ARGV; + ' "$duration" "$@" + } + fi +fi + # --- Load config defaults --- CONFIG_FILE="$LOOP_DIR/config.json" config_default() { get_config_value "$1" "$2"; }