[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
Draft
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
networksetup -getairportnetwork en0outputs:The previous code used
cut -d " " -f 4which only captures the 4th space-separated word — so SSIDs with spaces (likePASSAWIT'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):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_NAMEcapture