refactor(invocation): use path_slash for argv[0] normalization - #3379
Merged
Conversation
Replace the hand-rolled .to_string_lossy().replace('\\', "/") in
invocation_path() with path_slash::PathExt::to_slash_lossy(), the tool
CLAUDE.md's dependency table sanctions for path normalization. Extract a
pure normalize_invocation_path(&OsStr) helper so the logic is unit-testable.
Behavior-preserving for realistic argv[0]; the platform-aware helper is
strictly more correct for literal backslashes in Unix paths.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
max-sixty
added a commit
that referenced
this pull request
Jul 8, 2026
…indow (#3386) Five commits landed on `main` during #3385's CI wait, so they ship inside v0.66.0's tree but weren't in its changelog (the step-12 drift check in the release skill caught this). This adds the user-facing three to the 0.66.0 section: - **Codex activity markers** ([#3364](#3364), closes [#3362](#3362), thanks @ofek for reporting) - **SCP-style SSH remotes with custom usernames** ([#3371](#3371), thanks @fcoury-oai) - **Windows app-alias Settings path** ([#3372](#3372), thanks @ofek) Excluded as internal: #3360 (trait docstrings), #3379 (argv[0] display refactor). Every entry verified against the actual diffs. The v0.66.0 tag will point at this PR's squash commit so the tagged tree carries the complete changelog. 🤖 Generated with [Claude Code](https://claude.com/claude-code) > _This was written by Claude Code on behalf of Maximilian Roos_ Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
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.
Nightly code-quality sweep finding.
invocation_path()insrc/invocation.rshand-rolled.to_string_lossy().replace('\\', "/")to produce a forward-slash display path. That is the exact anti-pattern the "Use Existing Dependencies" table inCLAUDE.mdflags — the sanctioned tool for path normalization ispath_slash::PathExt::to_slash_lossy(), which is already used throughoutsrc/(e.g.src/path.rs,src/commands/config/state.rs,src/diagnostic.rs).This swaps the manual replacement for
to_slash_lossy(), extracted into a small pure helpernormalize_invocation_path(&OsStr)so the logic is unit-testable (the publicinvocation_path()readsstd::env::args_os()and can't be exercised directly).The switch is behavior-preserving for every realistic
argv[0]: on Unix, values likewt,./wt,target/debug/wt, and/usr/local/bin/wtcarry no backslashes, so normalization is a pass-through; on Windows, both the old replacement andto_slash_lossy()render\separators as/. The one semantic difference is strictly more correct —to_slash_lossy()is platform-aware, so a literal\in a Unix path (a valid filename character there, not a separator) is now left untouched rather than mangled. This function is display-only (it feedswt config showdebug output and shell-integration warnings), so no snapshots change; the test filters intests/common/mod.rsalready normalize both raw and forward-slash forms.Test: added
normalize_invocation_path_passes_through_forward_slash_paths(runs everywhere) plus a#[cfg(windows)]case pinning the\→/normalization. The pure helper had no prior unit coverage.