Skip to content

zsh: test ~/.zshenv with -f, not -d - #29

Merged
presto8 merged 1 commit into
mainfrom
fix/zshenv-file-test
Aug 28, 2026
Merged

presto8 merged 1 commit into
mainfrom
fix/zshenv-file-test

Conversation

@presto8

@presto8 presto8 commented Aug 28, 2026

Copy link
Copy Markdown
Owner

~/.zshenv is a file, so '-d' was never true and that half of the guard
was dead -- the intent was clearly to avoid clobbering a zsh setup the
user already has. The function then overwrites ~/.zshenv with a
heredoc, so the check matters.

In practice the '-d $ZPREZTODIR' half already short-circuited repeat
runs; this makes the script also leave a pre-existing ~/.zshenv alone
on a machine that has one but no prezto checkout.


🤖 Generated with Claude Code

~/.zshenv is a file, so '-d' was never true and that half of the guard
was dead -- the intent was clearly to avoid clobbering a zsh setup the
user already has. The function then overwrites ~/.zshenv with a
heredoc, so the check matters.

In practice the '-d $ZPREZTODIR' half already short-circuited repeat
runs; this makes the script also leave a pre-existing ~/.zshenv alone
on a machine that has one but no prezto checkout.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@presto8
presto8 requested a lite review from Copilot August 28, 2026 20:03
@presto8
presto8 merged commit 47b70b3 into main Aug 28, 2026
2 checks passed
@presto8
presto8 deleted the fix/zshenv-file-test branch August 28, 2026 20:04

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new -f guard still misses non-regular existing ~/.zshenv cases (e.g., directory/FIFO/broken symlink) that can cause the heredoc write to fail or block under set -e.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Updates the setup_zsh_with_prezto() bootstrap guard to correctly detect an existing ~/.zshenv file before writing a new one, preventing unintended overwrites when Prezto is not already present.

Changes:

  • Replace a dead -d "$HOME/.zshenv" directory check with a file check (-f) in the Prezto setup guard.
  • Clarify the intent of the guard with an updated comment.
File summaries
File Description
setup Fixes the zsh/Prezto setup guard so ~/.zshenv is detected as a file before the script overwrites it.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread setup
# prezto
if [[ -d "$HOME/.zshenv" || -d "$ZPREZTODIR" ]]; then
# prezto; bail out rather than clobber an existing zsh setup
if [[ -f "$HOME/.zshenv" || -d "$ZPREZTODIR" ]]; then
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants