fix: add macOS timeout compatibility (gtimeout or perl fallback)

This commit is contained in:
2026-03-27 12:24:53 -04:00
parent 0666903b5f
commit a3cf3e7bae

17
loop.sh
View File

@@ -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"; }