Skip to content

Conversation

@fvincenzo
Copy link
Contributor

After Darwin 25.0 ipconfig stopped displaying the correct SSID showing instead.
As a consequence of that the status bar stopped reporting the information.

Fix the issue maintaining compatibility with the old versions of MacOS.

@coderabbitai
Copy link

coderabbitai bot commented Dec 15, 2025

📝 Walkthrough

Walkthrough

Adds a new _get_wifi_ifname helper to detect the active Wi‑Fi interface on Darwin, replaces hardcoded en0 usage, trims leading whitespace from airport output, and adds a macOS productVersion branch (> 25.0) to choose between networksetup -listpreferredwirelessnetworks and ipconfig getsummary for SSID retrieval.

Changes

Cohort / File(s) Summary
Darwin network script
scripts/network.sh
Added exported helper _get_wifi_ifname to discover the active Wi‑Fi interface (with enX fallback); replaced hardcoded en0 with discovered interface for Wi‑Fi and airport queries; trimmed leading whitespace from airport output; added macOS productVersion branch (productVersion > 25.0 → networksetup -listpreferredwirelessnetworks, otherwise ipconfig getsummary).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Verify _get_wifi_ifname parsing and fallback behavior when no primary interface is found.
  • Check macOS productVersion comparison and boundary handling at 25.0.
  • Confirm whitespace trimming and subsequent conditionals correctly handle empty or unexpected airport output.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: fixing SSID display for WiFi networks, which aligns with the core objective of the changeset.
Description check ✅ Passed The description explains the problem (Darwin 25.0 ipconfig showing ''), its impact, and the solution (maintaining compatibility), which directly relates to the changeset.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 73f33e3 and 73ad821.

📒 Files selected for processing (1)
  • scripts/network.sh (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • scripts/network.sh

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
scripts/network.sh (2)

35-35: Cache _get_wifi_ifname result to avoid redundant calls.

The function is called three times (lines 35, 37, 40). Each call invokes scutil and multiple pipes. Store the result once and reuse it.

Apply this diff:

       if [[ $(sw_vers -productVersion) > "25.0" ]]; then
-        local wifi_network=$(networksetup -listpreferredwirelessnetworks "$(_get_wifi_ifname)" | awk 'NR==2 && sub("\t","") { print; exit }')
+        local ifname=$(_get_wifi_ifname)
+        local wifi_network=$(networksetup -listpreferredwirelessnetworks "$ifname" | awk 'NR==2 && sub("\t","") { print; exit }')
       else
-        local wifi_network=$(ipconfig getsummary "$(_get_wifi_ifname)" | awk -F ' SSID : '  '/ SSID : / {print $2}')
+        local ifname=$(_get_wifi_ifname)
+        local wifi_network=$(ipconfig getsummary "$ifname" | awk -F ' SSID : '  '/ SSID : / {print $2}')
       fi
 
-      local airport=$(networksetup -getairportnetwork "$(_get_wifi_ifname)" | cut -d ':' -f 2 | head -n 1)
+      local airport=$(networksetup -getairportnetwork "$ifname" | cut -d ':' -f 2 | head -n 1)

Also applies to: 37-37, 40-40


42-48: Whitespace handling in airport string comparison.

Line 42 checks if $airport equals the full error message, but after cut and head, it may have leading whitespace. The sed on line 43 only trims for the output, not for the condition check. Consider trimming before the comparison for clarity.

Apply this diff:

-      if [[ $airport != "You are not associated with an AirPort network." ]]; then
+      airport=$(echo "$airport" | sed 's/^[[:blank:]]*//g')
+      if [[ $airport != "You are not associated with an AirPort network." ]]; then
         echo "$wifi_label$airport" | sed 's/^[[:blank:]]*//g'

This trims whitespace once before both the check and the output, avoiding the redundant sed.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2b762b3 and e710fc2.

📒 Files selected for processing (1)
  • scripts/network.sh (2 hunks)
🧰 Additional context used
🪛 Shellcheck (0.11.0)
scripts/network.sh

[error] 34-34: Decimals are not supported. Either use integers only, or use bc or awk to compare.

(SC2072)


[warning] 35-35: Declare and assign separately to avoid masking return values.

(SC2155)


[warning] 37-37: Declare and assign separately to avoid masking return values.

(SC2155)


[warning] 40-40: Declare and assign separately to avoid masking return values.

(SC2155)

🔇 Additional comments (1)
scripts/network.sh (1)

13-18: Helper function looks good structurally.

The fallback logic to find the WiFi interface is sound, though both paths could potentially fail silently without validation.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e710fc2 and 73f33e3.

📒 Files selected for processing (1)
  • scripts/network.sh (2 hunks)
🧰 Additional context used
🪛 Shellcheck (0.11.0)
scripts/network.sh

[warning] 34-34: Declare and assign separately to avoid masking return values.

(SC2155)


[warning] 43-43: Declare and assign separately to avoid masking return values.

(SC2155)

🔇 Additional comments (2)
scripts/network.sh (2)

13-18: Good fallback approach for WiFi interface detection.

The function correctly attempts primary detection via scutil and gracefully falls back to pattern matching if needed. This should handle various macOS versions and configurations well.


37-37: Version comparison correctly uses numeric comparison.

The change from string comparison to bc -l properly handles multi-part version numbers (e.g., 25.10 vs 25.2), addressing the previous feedback.

After Darwin 25.0 ipconfig stopped displaying the correct SSID showing
<redacted> instead.
As a consequence of that the status bar stopped reporting the
information.

Fix the issue maintaining compatibility with the old versions of MacOS.

Signed-off-by: Vincenzo Frascino <[email protected]>
@Theoreticallyhugo
Copy link
Collaborator

Thank you very much for your contribution!
I've tested this on 26.2 and tmux 3.6a and it works very well.
If there are no objections in the next one to two days, I'll get this merged.

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants