fix: normalize Windows backslashes to forward slashes in cron bash script paths (#60857) - #60892
fix: normalize Windows backslashes to forward slashes in cron bash script paths (#60857)#60892kyssta-exe wants to merge 1 commit into
Conversation
|
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: Comment (token read-only)
PR 60892 normalizes Windows backslashes to forward slashes in cron bash script paths. Small fix (1 file, 5 additions, 1 deletion) for cross-platform compatibility.
LGTM - awaiting maintainer approval.
teknium1
left a comment
There was a problem hiding this comment.
Thanks for targeting a real native-Windows cron failure: current main still passes str(path) to Bash at cron/scheduler.py:2091, matching the reports in #60857 and #23404.
Problems
cron/scheduler.py:2094in this PR usesstr(path).replace("\\", "/")for every host. That rewrites literal backslashes in valid POSIX filenames, so it can change a validated script path into a different path on Linux/macOS.path.as_posix()performs the intended Windows conversion without that POSIX behavior change.
Suggested changes
- Replace the blanket string replacement with
path.as_posix()for the Bash argv element. - Add a focused regression assertion with
PureWindowsPath; the existing shell-script test attests/cron/test_cron_no_agent.py:288does not cover Windows serialization. Closed PR #43076 contains a minimal example of that test shape.
Automated hermes-sweeper review.
| # On Windows, MSYS2/Git Bash interprets backslashes as escape | ||
| # sequences, not path separators. Convert to POSIX forward | ||
| # slashes so C:\Users\... doesn't become C:Users... (#60857). | ||
| script_arg = str(path).replace("\\", "/") |
There was a problem hiding this comment.
Please use path.as_posix() here rather than replacing backslashes unconditionally. On POSIX, \ is a valid filename character, so this replacement can turn a validated script path into a different path; as_posix() still converts native Windows paths as required.
|
Stale — no merge activity for 4-6 days. Can resubmit if still needed. |
On Windows, MSYS2/Git Bash interprets backslashes as escape sequences, not path separators. Convert backslashes to POSIX forward slashes before passing the script path to bash.