Skip to content

fix(terminal): preserve PowerShell expressions in env assignments - #1099

Open
Aschenbath wants to merge 1 commit into
Kuddev:mainfrom
Aschenbath:fix/oss20-20261124-04c7-pebrel-env-literal
Open

Aschenbath wants to merge 1 commit into
Kuddev:mainfrom
Aschenbath:fix/oss20-20261124-04c7-pebrel-env-literal

Conversation

@Aschenbath

Copy link
Copy Markdown
Contributor

Result / 用户结果

$env:X = Read-Host 'prompt' -MaskInput now reaches PowerShell unchanged, so it prompts for input instead of storing the command text in the variable. Bare token conveniences such as API-token-shaped values, URLs and email addresses remain quoted.

Fixes #1092.

Design / 设计边界

The change belongs to the existing shell-integration rewrite function in pebrel_terminal. The entire right-hand value must be one bare token; whitespace, embedded quotes, variables, delimiters and comments prevent rewriting. PowerShell's token parser also rejects whitespace-free arithmetic such as 1+2. This preserves the existing single-token convenience without interpreting multi-token native commands as text. No interfaces, dependencies, persistence formats, threads or UI changed.

Evidence / 验证依据

  • The native PowerShell regression fails on the original function and passes with this fix. It covers Read-Host, commands with arguments, arithmetic, interpolation, quoted values, arrays/comments, and supported bare tokens.
  • Rust 1.97.1: cargo fmt --all --check passes. python scripts/check_architecture.py --base 76f74be1 passes without changing budgets.
  • cargo test -p pebrel_terminal --locked -j 6 built the terminal and passed 462 tests; two proxy tests required PowerShell 7, which was initially absent from PATH. After adding the existing PowerShell 7.6.9 installation to this test process's PATH, the same compiled test binary passed all 464 tests, with 2 ignored. The new regression ran against Windows PowerShell 5.1 and PowerShell 7.6.9.
  • The optional all-target terminal Clippy attempt reports 34 pre-existing test/lint errors outside this diff (including powershell_launch.rs and graphics_matrix.rs). No lint suppression or unrelated cleanup is included.
  • Full GPUI application, interactive password entry and graphical ConPTY acceptance were not run. The regression validates the production rewrite function through real PowerShell processes.

Required Review / 必须确认

  • Followed CONTRIBUTING.md, docs/architecture.md and docs/project-constraints.md.
  • Existing responsibility and behavior authority retained.
  • Architecture check passes against the actual PR base; no budget changes.
  • Success/failure behavior covered; platform limits listed above.
  • No new UI messages or governance changes; those checks are not applicable.

@Aschenbath
Aschenbath requested a review from Kuddev as a code owner November 24, 2026 05:10
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.

[Bug] PowerShell 裸 env 赋值改写过度:$env:X = Read-Host ... 被当成字面量包成字符串

1 participant