Skip to content

Clean up blank lines and orphaned comments in PATH config files#454

Merged
shannah merged 1 commit intomasterfrom
claude/cleanup-zshrc-blanks-UZ0vB
Apr 8, 2026
Merged

Clean up blank lines and orphaned comments in PATH config files#454
shannah merged 1 commit intomasterfrom
claude/cleanup-zshrc-blanks-UZ0vB

Conversation

@shannah
Copy link
Copy Markdown
Owner

@shannah shannah commented Apr 8, 2026

Summary

Improves the handling of PATH configuration files by cleaning up excessive blank lines and removing orphaned jDeploy installer comments during both add and remove operations.

Key Changes

  • Add operation: Trims trailing whitespace before appending new PATH entries and uses a single blank line separator to prevent accumulation of blank lines
  • Remove operation:
    • Detects and removes orphaned "Added by jDeploy installer" comments that aren't followed by the corresponding PATH export
    • Collapses multiple consecutive blank lines (3+) into at most one blank line
    • Trims trailing blank lines while preserving a single trailing newline
  • Test coverage: Added 6 comprehensive test cases covering blank line cleanup, orphaned comment removal, and preservation of non-jDeploy content

Implementation Details

  • The add operation now reads the current file content, trims trailing whitespace, and rewrites the entire file to ensure clean formatting
  • The remove operation includes lookahead logic to identify orphaned comments and end-of-file comments
  • Blank line normalization uses regex patterns to handle edge cases consistently
  • All changes maintain backward compatibility and preserve non-jDeploy configuration entries

https://claude.ai/code/session_01D3Pey4PcNjGphHHbbADRdC

When jDeploy installs/uninstalls CLI commands, it adds and removes PATH
entries from .zshrc/.bashrc. Over repeated cycles, this left behind
accumulating blank lines and orphaned "# Added by jDeploy installer"
comments (not followed by an export line).

Three fixes in UnixPathManager:
- removePathFromConfigFile: collapse 3+ consecutive blank lines to one
- removePathFromConfigFile: remove orphaned jDeploy comments (not
  followed by an export PATH line)
- addPathToConfigFile: trim trailing whitespace before appending new
  entry, preventing blank line accumulation

https://claude.ai/code/session_01D3Pey4PcNjGphHHbbADRdC
@shannah shannah merged commit 5c77363 into master Apr 8, 2026
17 checks passed
@shannah shannah deleted the claude/cleanup-zshrc-blanks-UZ0vB branch April 8, 2026 17:14
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