Skip to content

[dotfiles-improvement] perf: replace $(date +%s) with $EPOCHSECONDS ZSH built-in - #531

Draft
github-actions[bot] wants to merge 1 commit into
mainfrom
fix/epochseconds-no-subshell-1378e8c9568c081e
Draft

[dotfiles-improvement] perf: replace $(date +%s) with $EPOCHSECONDS ZSH built-in#531
github-actions[bot] wants to merge 1 commit into
mainfrom
fix/epochseconds-no-subshell-1378e8c9568c081e

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

What

Five places in linux-dev.zsh and s3-minio-aws.zsh generate unique resource names using $(date +%s) to get a Unix timestamp:

# Before (spawns a subshell + forks date(1) each call)
key_name="ec2-linux-tmp-$(date +%s)-${RANDOM}"

Change

Replace with ZSH's built-in $EPOCHSECONDS parameter:

# After (pure ZSH, no subshell, no fork)
key_name="ec2-linux-tmp-${EPOCHSECONDS}-${RANDOM}"

$EPOCHSECONDS is a ZSH special parameter (available since ZSH 5.0) that returns the current Unix timestamp without spawning a subshell or forking date(1). The value is semantically identical to $(date +%s).

Affected locations (5 occurrences)

  • zsh/functions/linux-dev.zshec2-linux, az-linux, gcp-linux unique name generators (4 occurrences)
  • zsh/functions/s3/s3-minio-aws.zsh — test pod name (1 occurrence)

No behavior change

The generated names have identical format and uniqueness properties.

Generated by Dotfiles Improvement Scanner · ● 63.7M ·

$EPOCHSECONDS is a ZSH special parameter that returns the current Unix
timestamp without spawning a subshell or forking a date(1) process.

Affected: linux-dev.zsh (4 unique-name generators), s3-minio-aws.zsh (1).

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