[DRAFT] PowerShell shell plugins: bug-fix pass

Aperta
#2,263 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@instinct-vfx ci sta già lavorando.

Dal 24/11/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

os:windows shell

This issue is an overarching tracking issue for a bug-fix pass I am doing on the PowerShell plugins. Disclaimer: AI was rather heavily used both in finding potential issues, verifying them, coming up with a plan and checking if there are already reports or PRs.

Everything listed was reproduced with the rez-env and rez-context command line tools of a production install (install.py, Python 3.13) on Windows 11, with Windows PowerShell 5.1 and two versions of pwsh: 7.2.2, and 7.6.10, which is the version on the GitHub Windows runners. The results are the same on both pwsh versions. Not covered: pwsh on Linux and macOS.

New issues
  • #TODO(escaping): env values and info() text are not escaped (backtick, typographic quotes)
  • #TODO(parse-failure): a context script that fails to parse is ignored and rez exits 0
  • #TODO(env-var-separators): env_var_separators is ignored when appending or prepending
  • #TODO(stale-lastexitcode): exit code of a package command leaks into the exit code of rez env
  • #TODO(argument-quoting): rez env -- <args> mangles arguments containing -x.y, @, a comma or a backtick
  • #TODO(script-encoding): non-ASCII text is corrupted because generated scripts have no BOM
  • #TODO(env-var-regex): $VAR references are cut at the first digit in the variable name (core rex, all shells)

The escaping fix has to land before, or together with, the encoding fix. The others are independent of each other.

Existing issues, with new information
  • AcademySoftwareFoundation/rez#1413, eval output joined with &&. Besides being invalid in Windows PowerShell, && also loses statements in pwsh 7, because it short-circuits. unsetenv() on a variable that is not set emits Remove-Item -ErrorAction SilentlyContinue, which leaves $? false, and every statement after it is skipped. Reproduced with a package whose commands() are unsetenv("NOT_SET") followed by env.AFTER = "1": after running the output of rez-context ctx.rxt --interpret --format pwsh --style eval in pwsh 7.2, AFTER is not set. So ; is needed in both plugins, not only in powershell.

  • AcademySoftwareFoundation/rez#1406, detached shells. rez-env --shell pwsh --detached <pkg> -- <command> still fails with FileNotFoundError. There are three separate defects:

    • START is a cmd builtin, so Popen needs shell=True, as cmd.py already does.
    • -NoExit is inserted at index 1, which is before the executable whenever pre_command is set.
    • START treats a first quoted argument as the window title, and the default pwsh path contains a space. An empty title has to be inserted: START "" "C:\Program Files\PowerShell\7\pwsh.exe" ....

    With all three addressed in a prototype, rez-env --detached works in both editions.

  • AcademySoftwareFoundation/rez#1728, alias with a quoted path. Prefixing the call operator only when the alias value starts with a quote fixes the reported case in both editions. Such values are a syntax error today, unless they are a PowerShell expression that begins with a string literal, so this avoids the compatibility risk of adding & unconditionally.

Already covered by open PRs
  • resetenv() crashes: AcademySoftwareFoundation/rez#2068, fixed for all shells in AcademySoftwareFoundation/rez#2070.
  • --norc is ignored: AcademySoftwareFoundation/rez#1777 adds -NoProfile. That PR also moves -NoExit, so it overlaps with the fix for AcademySoftwareFoundation/rez#1406.
Not part of this pass
  • $ in rez env -- <args> is expanded by PowerShell: AcademySoftwareFoundation/rez#1803, AcademySoftwareFoundation/rez#1566, AcademySoftwareFoundation/rez#1764. This is a design question, because arguments are double-quoted on purpose.
  • A ${VAR} reference that rex cannot resolve is written to the script as a PowerShell variable, not an environment variable, so it expands to nothing: AcademySoftwareFoundation/rez#768.
Lingua principale
Python
Stelle
1.1k
Fork
370
Merge medio
2g 10h
PR unite (30g)
11

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di AcademySoftwareFoundation/rez

Tutte le issue di AcademySoftwareFoundation/rez

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.