Repository navigation
fix: rotate logs without splitting workspace paths on whitespace - #21
Open
ismailvc1111 wants to merge 1 commit into
Open
ismailvc1111 wants to merge 1 commit into
ismailvc1111 wants to merge 1 commit into
Conversation
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.
|
All contributors have signed the CLA ✍️ ✅ |
Author
|
I have read the CLA Document and I hereby sign the CLA |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #19.
rotate_logspipedlsintoxargs, which splits on whitespace. With a workspace path containing a space, each log path was torn in two and both fragments went torm -f --. The fragment before the space could delete an unrelated file outside the log directory, andRALPH_LOOP_MAX_LOGSstopped being enforced.The fix walks the log directory with
findNUL-delimited, sorts newest first, and removes each entry pastmax_logsby its exact path. It only touches*.logfiles directly inside$log_dir.Validation:
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 onmainand 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 fskips symlinks, which the oldlspath did not, so symlinked.logfiles are no longer rotated. I think that is the safer behavior, but flagging it for review.