Skip to content

fix: rotate logs without splitting workspace paths on whitespace - #21

Open
ismailvc1111 wants to merge 1 commit into
SantanderAI:mainfrom
ismailvc1111:fix/log-rotation-paths-with-spaces
Open

ismailvc1111 wants to merge 1 commit into
SantanderAI:mainfrom
ismailvc1111:fix/log-rotation-paths-with-spaces

Conversation

@ismailvc1111

Copy link
Copy Markdown

Fixes #19.

rotate_logs piped ls into xargs, which splits on whitespace. With a workspace path containing a space, each log path was torn in two and both fragments went to rm -f --. The fragment before the space could delete an unrelated file outside the log directory, and RALPH_LOOP_MAX_LOGS stopped being enforced.

The fix walks the log directory with find NUL-delimited, sorts newest first, and removes each entry past max_logs by its exact path. It only touches *.log files directly inside $log_dir.

Validation:

  • Added two regression tests to tests/ralph-loop.bats, matching the report: rotation still trims when the path contains a space, and a file outside the log directory is never removed. Both fail on main and pass with this change.
  • bats tests/ralph-loop.bats: 10/10 pass.
  • shellcheck --severity=warning ralph-loop.sh (the CI gate): clean.

Note: find -type f skips symlinks, which the old ls path did not, so symlinked .log files are no longer rotated. I think that is the safer behavior, but flagging it for review.

rotate_logs piped ls into xargs, which splits on whitespace. With a
workspace path containing a space (for example ~/Google Drive/...),
each log path was torn into two arguments and both were passed to
rm -f. The fragment before the space could delete an unrelated file
outside the log directory, and rotation stopped trimming logs.

Walk the log directory with find, NUL-delimited, and remove each
entry past RALPH_LOOP_MAX_LOGS by its exact path.

Adds two regression tests: rotation still trims when the path has a
space, and a file outside the log directory is never removed.
@ismailvc1111
ismailvc1111 requested review from a team as code owners October 3, 2026 11:21
@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@ismailvc1111

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Oct 3, 2026
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.

Log rotation deletes a file outside the log directory when the workspace path contains a space

1 participant