fix(launcher): restore caller environment after play.ps1 #563

Open
github-bot wants to merge 1 commit from github-bot/gh-563 into a-publier AGit
Owner

@⁠lgtlgt0015-code on GitHub · 2026-11-27 11:37 UTC · original
lgtlgt0015-code:codex/restore-launcher-environment → a-publier · +25 −11 · 1 files · 1 commits · open

Running play.ps1 from an existing PowerShell session changes that session's environment. For example, the launcher replaces an inherited VICTORY_RELAY with 2 and leaves it there after the game exits. It can also remove inherited variables permanently from that shell.

Save the original value of each variable the launcher touches and restore it in finally. The game still gets the launcher presets and -More overrides, while the caller gets its original values back, including whether each variable was set. This does not change the exit-code propagation or messages covered by #459.

Verified with a local test executable on PowerShell 7 and Windows PowerShell 5.1. Reproduced the leak on the base branch. Checked that the child receives the expected settings and a path containing spaces, and that the patched launcher restores the caller's settings after both a normal exit and a terminating native-command error. No game files were used.

**@⁠lgtlgt0015-code** on GitHub · 2026-11-27 11:37 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/563) `lgtlgt0015-code:codex/restore-launcher-environment` → `a-publier` · +25 −11 · 1 files · 1 commits · open Running `play.ps1` from an existing PowerShell session changes that session's environment. For example, the launcher replaces an inherited `VICTORY_RELAY` with `2` and leaves it there after the game exits. It can also remove inherited variables permanently from that shell. Save the original value of each variable the launcher touches and restore it in `finally`. The game still gets the launcher presets and `-More` overrides, while the caller gets its original values back, including whether each variable was set. This does not change the exit-code propagation or messages covered by #459. Verified with a local test executable on PowerShell 7 and Windows PowerShell 5.1. Reproduced the leak on the base branch. Checked that the child receives the expected settings and a path containing spaces, and that the patched launcher restores the caller's settings after both a normal exit and a terminating native-command error. No game files were used.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 11:54:44 +00:00
Author
Owner

@⁠AccelArch on GitHub · 2026-11-27 11:56 UTC · original

Read 8765c8b against a-publier (4eb6cfd). Tested on Windows PowerShell 5.1.26100 with a stand-in victory.exe (a small program that prints its VICTORY_* environment and returns the exit code from STANDIN_EXIT), running scripts/play.ps1 from a session with VICTORY_RELAY=9, VICTORY_FOO=x and VICTORY_CONFIG=cfg.toml:

  • the child's environment is the same on base and with this PR (VICTORY_RELAY=2, no VICTORY_FOO, VICTORY_CONFIG kept, plus the presets);
  • afterwards, base leaves VICTORY_RELAY=2 and VICTORY_THIN=1 in the caller and drops VICTORY_FOO; with this PR the caller has VICTORY_RELAY=9, VICTORY_FOO=x and VICTORY_THIN unset;
  • a child exit code of 5 reaches $LASTEXITCODE on both, so #459's behavior is unchanged;
  • a fresh session (no VICTORY_) and -More @{VICTORY_XTRA='1'; VICTORY_RELAY='7'} also leave no VICTORY_ behind.
    Not tested: PowerShell 7 and Ctrl-C during a run.

AI-assisted.

**@⁠AccelArch** on GitHub · 2026-11-27 11:56 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/563#issuecomment-7217643106) Read 8765c8b against a-publier (4eb6cfd). Tested on Windows PowerShell 5.1.26100 with a stand-in victory.exe (a small program that prints its VICTORY_* environment and returns the exit code from STANDIN_EXIT), running scripts/play.ps1 from a session with VICTORY_RELAY=9, VICTORY_FOO=x and VICTORY_CONFIG=cfg.toml: - the child's environment is the same on base and with this PR (VICTORY_RELAY=2, no VICTORY_FOO, VICTORY_CONFIG kept, plus the presets); - afterwards, base leaves VICTORY_RELAY=2 and VICTORY_THIN=1 in the caller and drops VICTORY_FOO; with this PR the caller has VICTORY_RELAY=9, VICTORY_FOO=x and VICTORY_THIN unset; - a child exit code of 5 reaches $LASTEXITCODE on both, so #459's behavior is unchanged; - a fresh session (no VICTORY_*) and -More @{VICTORY_XTRA='1'; VICTORY_RELAY='7'} also leave no VICTORY_* behind. Not tested: PowerShell 7 and Ctrl-C during a run. AI-assisted.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/563/head:github-bot/gh-563'
git switch 'github-bot/gh-563'

Merge

Merge the changes and update on Forgejo.
git switch 'a-publier'
git merge --no-ff 'github-bot/gh-563'
git switch 'github-bot/gh-563'
git rebase 'a-publier'
git switch 'a-publier'
git merge --ff-only 'github-bot/gh-563'
git switch 'github-bot/gh-563'
git rebase 'a-publier'
git switch 'a-publier'
git merge --no-ff 'github-bot/gh-563'
git switch 'a-publier'
git merge --squash 'github-bot/gh-563'
git switch 'a-publier'
git merge --ff-only 'github-bot/gh-563'
git switch 'a-publier'
git merge 'github-bot/gh-563'
git push origin 'a-publier'
This discussion has been locked. Commenting is limited to contributors.
No description provided.