Skip to content

[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
mainfrom
fix/dotfiles-printf-hex-to-zsh-arith-1784341354-90ad05f71fa65f69
Draft

[dotfiles-improvement] fix: replace printf '%x' with ZSH arithmetic hex expansion in randomize-mac#535
github-actions[bot] wants to merge 1 commit into
mainfrom
fix/dotfiles-printf-hex-to-zsh-arith-1784341354-90ad05f71fa65f69

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Replace $(printf '%x' $((RANDOM % 16))) (subshell + process fork) with ZSH-native $(( [##16] (RANDOM % 16) )) arithmetic hex expansion in randomize-mac.zsh.

Changes

  • zsh/functions/randomize-mac.zsh: Two instances updated — initial generation and the while loop re-roll
  • Add ${last_digit:l} lowercase modifier to ensure hex digits af (not AF), matching ifconfig output format so the MAC verification comparison at the end of the function succeeds reliably

Why

[##16] is a ZSH-specific arithmetic base-conversion flag that avoids spawning a subshell and forking printf for every hex digit generated. The :l modifier is already idiomatic ZSH.

Generated by Dotfiles Improvement Scanner · ● 61.4M ·

…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>
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