Repository navigation
cross-platform: gate residual Windows assumptions outside cfg(windows) + stale doc claims - #499
Merged
Merged
Conversation
Non-cfg-layer Windows-hardcode audit (sister of the cfg-gate audit #492). b-class fixes (wrong on non-Windows builds): - tilde.rs home_value(): the USERPROFILE fallback (env_vars lookup + process env) ran un-gated, so a stray USERPROFILE exported by cross-platform tooling would hijack `~` on unix once HOME is unset. Now cfg(windows)-gated; unix keeps the empty default it always had. - main.rs identity disclosure/report: on non-Windows builds the persona is always native, but --help/--identity still advertised "unset RUBASH_IDENTITY to return to msys". Platform-split so unix prints an n/a switch line instead of an impossible instruction. c-class fixes (stale/dangling copy): - build_info.rs --version note pointed to docs/platform-support.md, which does not exist; repointed to the README identity section (both anchoring assertions updated). - README.md/README.zh-CN.md Quick Start still claimed "full functionality requires Windows today", contradicting the Platform status section (Linux native runs, macOS CI-green). - README.md identity section now states non-Windows builds always report the honest-native identity. Windows behavior is byte-identical (all edits are unix-arm additions or cfg(windows)-scoped text). Verified: cargo check --lib + cargo test --lib (642 passed; 2 pre-existing environment-dependent failures also failing on pristine origin/master) + cargo check --lib --target x86_64-unknown-linux-gnu.
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.
Non-cfg-layer Windows-hardcode audit
Sister of the cfg-gate audit (#492). Scope: Windows assumptions that live outside
cfg(windows)gates — strings, defaults, docs, product behavior. Classification: (a) legitimate Windows-native code behind cfg gates — kept; (b) Windows assumptions wrongly active/visible on non-Windows builds — fixed; (c) stale/dangling docs & copy — fixed. Report-only items were deliberately not touched (see footer).Base: origin/master @ 61dd62f. Windows behavior byte-identical (unix-arm additions or cfg(windows)-scoped text only).
Fixed in this PR
src/expand/tilde/tilde.rs—home_value()env_vars.get("USERPROFILE")+env::var("USERPROFILE")) ran un-gated; a stray USERPROFILE exported by cross-platform tooling would hijack~on unix once HOME is unset. Ledger E9 revision planned this gate ("随 getpwnam 改造一并") but it never landed.""— identical to today's unix behavior (HOME unset + no USERPROFILE). The pre-existingwindows_home_value_prefers_home_before_userprofiletest was already cfg(windows).src/main.rs—print_identity_disclosure()(--help)switch: unset RUBASH_IDENTITY (or set any other value) to return to msys— false on non-Windows builds wherecurrent_identity()is hardwired Native (identity.rs:42-50).persona: native (honest-native; non-Windows builds are always native)andswitch: n/a (RUBASH_IDENTITY only selects personas on Windows). Windows msys/native text unchanged.src/main.rs—print_identity_report()(--identity)RUBASH_IDENTITY=native; honest-native(implies the var was set) and the msys-default switch line.non-Windows build; honest-native+ n/a switch line. Windows text unchanged.src/build_info.rs—version_appendix()(Windows--versionnote)docs/platform-support.md— the file does not exist anywhere in the repo; both test assertions anchored the dangling path.README.md, Identity and Compatibility(where the persona contract actually lives);src/build_info.rs:107+tests/cli_tests.rs:4146assertions updated.README.md— Quick Start / Build from Source> Full functionality requires Windows today.directly contradicted the Platform status section 130 lines above (Linux native runs verified in WSL, macOS CI-green).README.zh-CN.md— 从源码构建> 完整功能当前需要 Windows。— same stale claim.README.md— Identity section, default-persona bulletidentity.rsmodule docs (non-Windows builds always report honest-native).Verified correct — no change needed (a-class spot checks)
src/executor/external_inner.rs—materialize_required_windows_env#[cfg(windows)]real body +#[cfg(not(windows))]no-op (ledger E8 fixed). SystemRoot/WINDIR/ComSpec copies at :287 also#[cfg(windows)].src/executor/path.rs—apply_required_windows_child_environmentsrc/executor/path.rs—windows_command_processor()(C:\Windows\System32\cmd.exefallback)is_windows_batch_file()/is_windows_powershell_script()which embedcfg!(windows)and return false on unix.src/executor/init.rs#[cfg(windows)](ledger E4/E19 fixed).src/executor/path.rs—standard_path()confstr(_CS_PATH)(ledger E5 fixed).src/executor/path.rs—has_path_separator/shell_path_to_process/(ledger E7 fixed).src/executor/lookup_paths.rs—/usr/bin/mv,/bin/{cat,ls}suite bridge#[cfg(windows)](ledger E2 fixed).src/executor/identity.rssrc/locale.rsplatform_collatecfg pair; windows-sys import gated.src/proc_vfs.rs,src/fd/windows_impl.rs,src/console_readline.rssrc/executor/local_helpers.rs—safe_temp_dir_string()/tmp(rubash#232).src/executor/job_builtins.rs—fcdefaultvi;script_driver.rsPS1 default\s-\v\$C:\.../System32literals#[cfg(windows)]bodies, doc comments, or#[cfg(test)]fixtures.Reported — deliberately NOT changed
src/bin/bash.rs+Cargo.toml[[bin]] name="bash"locate_shell()probes onlyniu.exe/winuxsh.exe, so on unix the shim always exits 127; worse, unix builds ship abashbinary that can shadow the system bash in PATH. Ledger routes this to the C2 release batch (two-part: platform-split probe names + unix release stops installing the shim).docs/host-contract.md:73.src/executor/support_names.rs:763—executable_extensions();-split helper; sole caller (lookup_paths.rs:139) is cfg-gated. Ledger E7 revision recommends renaming to prevent future misuse..replace('\\', "/")normalizations (external_finish.rs,lookup_paths.rs,init.rs,external_file_builtins.rs, …)\renders lossily in display paths.~with HOME unset expands to""(all platforms)echo ~prints~).~has no unix getpwuid fallback (ledger E9 follow-up)~is empty instead of passwd home.Verification
cargo fmtclean.cargo check --lib(x86_64-pc-windows-msvc): clean.cargo test --lib: 642 passed; 2 failed —builtins::pwd::tests::logical_mode_reports_posix_drive_pwd_by_defaultandexecutor::path::tests::virtual_system_root_operand_resolution_keeps_option_b_and_legacy_verbatim; both fail identically on pristine origin/master (WSL-interop environment-dependent assertions, e.g. expects/mnt/c), i.e. pre-existing, no new failures.cargo check --lib --target x86_64-unknown-linux-gnu: clean (unix arm compiles).cargo test --libruns: pending CI on this PR (no local linux toolchain for test execution).Conflict hygiene: no changes in cfg-gate audit territory (#492), lexer word/scanner (#462 neighborhood), or the executor hot path (#242 neighborhood).