[dotfiles-improvement] fix: replace printf '%x' with ZSH arithmetic hex expansion in randomize-mac - #535
Draft
github-actions[bot] wants to merge 1 commit into
Conversation
…ze-mac Use ZSH-native $(( [##16] N )) arithmetic expansion instead of spawning a subshell + printf process for hex conversion. Add :l modifier to ensure lowercase output (matching ifconfig output format) so MAC verification comparison succeeds reliably. 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.
Replace
$(printf '%x' $((RANDOM % 16)))(subshell + process fork) with ZSH-native$(( [##16] (RANDOM % 16) ))arithmetic hex expansion inrandomize-mac.zsh.Changes
zsh/functions/randomize-mac.zsh: Two instances updated — initial generation and thewhileloop re-roll${last_digit:l}lowercase modifier to ensure hex digitsa–f(notA–F), matchingifconfigoutput format so the MAC verification comparison at the end of the function succeeds reliablyWhy
[##16]is a ZSH-specific arithmetic base-conversion flag that avoids spawning a subshell and forkingprintffor every hex digit generated. The:lmodifier is already idiomatic ZSH.