Files
nimbus-eth2/scripts/getopt-wrapper.sh
Marko Burčul 6fff96c7a9 test(ci): check if macos build is stable on nix-darwin host (#8163)
* test(ci): check if macos build is stable on nix-darwin host

Signed-off-by: markoburcul <marko@status.im>

* fix(ci): prefer GNU getopt from PATH over hardcoded Homebrew paths

Check if GNU getopt is available in PATH before falling back to
Homebrew-specific paths. This supports nix-darwin and other package
managers that install GNU getopt outside of Homebrew.

Also updates DYLD_LIBRARY_PATH discovery to check standard
locations before assuming Homebrew.

Signed-off-by: markoburcul <marko@status.im>

---------

Signed-off-by: markoburcul <marko@status.im>
2026-04-17 13:40:15 +00:00

21 lines
544 B
Bash
Executable File

#!/usr/bin/env bash
# scripts/getopt-wrapper.sh - exec GNU getopt on any platform.
set -eu
if [ "$(uname)" != "Darwin" ]; then
exec getopt "$@"
fi
# macOS: prefer getopt in PATH if it's GNU (exit 4 from --test), else Homebrew.
getopt --test > /dev/null 2>&1 && rc=0 || rc=$?
if [ "$rc" -eq 4 ]; then
exec getopt "$@"
fi
for c in /opt/homebrew/opt/gnu-getopt/bin/getopt /usr/local/opt/gnu-getopt/bin/getopt; do
[ -x "$c" ] && exec "$c" "$@"
done
echo "GNU getopt not installed. Install via 'brew install gnu-getopt'." >&2
exit 1