Skip to content

[dotfiles-improvement] fix: replace cut -d ' ' -f 4 with ZSH expansion for WIFI_NAME - #534

Draft
github-actions[bot] wants to merge 1 commit into
mainfrom
fix/dotfiles-wifi-name-spaces-6e366ac705e73394
Draft

[dotfiles-improvement] fix: replace cut -d ' ' -f 4 with ZSH expansion for WIFI_NAME#534
github-actions[bot] wants to merge 1 commit into
mainfrom
fix/dotfiles-wifi-name-spaces-6e366ac705e73394

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Bug

networksetup -getairportnetwork en0 outputs:

Current Wi-Fi Network: SSID Name Here

The previous code used cut -d " " -f 4 which only captures the 4th space-separated word — so SSIDs with spaces (like PASSAWIT's Z Fold7) were silently truncated to just the first word. This caused the proxy check at line 131 to never match for multi-word SSIDs.

Fix

Replace with ZSH parameter expansion that strips the Current Wi-Fi Network: prefix and keeps the full remainder (including spaces):

# Before (spawns subshell + fork to cut; truncates multi-word SSIDs)
WIFI_NAME=$(networksetup -getairportnetwork "${_WIFI_IFACE:-en0}" 2>/dev/null | cut -d " " -f 4)

# After (pure ZSH; correctly captures multi-word SSIDs)
WIFI_NAME=${$(networksetup -getairportnetwork "${_WIFI_IFACE:-en0}" 2>/dev/null)#Current Wi-Fi Network: }

When not connected, the output is You are not associated with an AirPort network. — the #Current Wi-Fi Network: strip finds no match and WIFI_NAME is set to that full string, which still fails any SSID equality check. Behavior when disconnected is unchanged.

Affected file

  • zsh/macos-notvscode.zsh — line 124, WIFI_NAME capture

Generated by Dotfiles Improvement Scanner · ● 37.9M ·

networksetup -getairportnetwork outputs 'Current Wi-Fi Network: SSID Name'
and cut -d ' ' -f 4 only captures the first word of the SSID. SSIDs with
spaces (e.g. 'PASSAWIT's Z Fold7') were silently truncated, causing the
proxy check on line 131 to never match.

Replace with ZSH parameter expansion ${cmd#prefix} which strips
'Current Wi-Fi Network: ' prefix and captures the full SSID including spaces.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants