Skip to content

feat: add macOS support - #33

Open
geibos wants to merge 1 commit into
vernette:masterfrom
geibos:macos-support
Open

geibos wants to merge 1 commit into
vernette:masterfrom
geibos:macos-support

Conversation

@geibos

@geibos geibos commented Sep 19, 2026

Copy link
Copy Markdown

Adds macOS support so ipregion.sh runs on Darwin without modification.

What's included

  • Bash 4+ guard — macOS ships Bash 3.2. The script now detects an old Bash and re-execs itself with Homebrew's Bash (/opt/homebrew/bin/bash on Apple Silicon, /usr/local/bin/bash on Intel), or prints install instructions and exits if neither is present.
  • grep -P replacement — BSD grep has no PCRE support. grep_wrapper --perl now shells out to perl instead, which is present on every macOS install.
  • Distro/package manager detectionDarwin maps to macosbrew install.
  • Interface detection — there is no ip command; check_ip_interfaces parses ifconfig output on Darwin, skipping loopback (127.) and link-local (fe80:, ::1) addresses.
  • head -n -1 / tail -n +3 replacement — BSD head does not accept negative line counts. Replaced with Bash parameter expansion, which behaves identically on both platforms.
  • README — added a macOS install section, and corrected the dependency list to name column directly (the util-linux/bsdmainutils package names are Linux-specific; the actual dependency is the column binary).

Testing

Verified on macOS 15 (Darwin 24.6.0, Apple Silicon) with Bash 5.3:

  • bash -n ipregion.sh — clean
  • ./ipregion.sh --help
  • ./ipregion.sh -g primary -4 — full run, all GeoIP services resolved correctly

No Linux behaviour is changed: every new branch is gated on $OS_NAME == "Darwin", except the --perl wrapper and the head/tail replacements, which are portable and produce identical output on both platforms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant