fix: add timeout fallback for macOS compatibility

The `timeout` command (GNU Coreutils) is not available by default on macOS,
causing the installation script to fail with 'timeout: command not found'
during git clone.

This adds a shell function fallback that:
- Uses `gtimeout` if Homebrew coreutils is installed
- Otherwise skips the timeout and runs the command directly
This commit is contained in:
Moliang Zhou
2026-04-12 11:18:44 -07:00
parent 12e8c3d449
commit f79a915136

14
run.sh
View File

@@ -28,6 +28,20 @@ if [ -z "$BASH_VERSION" ]; then
exit 1 exit 1
fi fi
# Fallback for 'timeout' on macOS where GNU Coreutils is not installed by default.
# If 'gtimeout' (Homebrew's coreutils) is present, we use it. Otherwise, we gracefully
# degrade by using `shift` to discard the time limit argument ($1) and executing the rest of the command.
if ! command -v timeout &> /dev/null; then
timeout() {
if command -v gtimeout &> /dev/null; then
gtimeout "$@"
else
shift
"$@"
fi
}
fi
# Get current script directory # Get current script directory
export BASE_DIR=$(cd "$(dirname "$0")"; pwd) export BASE_DIR=$(cd "$(dirname "$0")"; pwd)