launcher: propagate the run's exit code and report discarded values #459

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

@⁠Jackster on GitHub · 2026-11-27 03:16 UTC · original
Jackster:launcher/exit-code → a-publier · +25 −7 · 1 files · 1 commits · open

What

Two defects in scripts/play.ps1, the launcher the README documents.

1. It swallowed the exit code. The script ended with

try { & $victory run $Exe --execute } finally { Pop-Location }

so a failing run left the caller with 0 — a wrapper or CI job cannot tell "the game ran" from "the FSR DLL was missing". Measured with the same script shape: child exits 7, caller saw 0. Now the code is taken right after the call, Pop-Location still runs, and the script exits with it. Verified on this branch with the real launcher and a malformed-title file (never starts the title): the caller now sees 1 where it saw 0. A $code = 1 default covers a failure that never reaches the child's code.

2. The "Discarded inherited values" message misreported. The old comparison ran after the script had set its own values, so a name the script overrides with a different value was reported as discarded, and the message could not distinguish "dropped" from "replaced". Now the script snapshots the inherited values before removing them and reports two accurate things:

  • Discarded — removed, and this script does not set the name again: the actionable case for -More.
  • Overridden — this script sets it to a different value: a separate sentence, so the user knows their value was replaced rather than lost.

A name the script sets to the same value is silent (it is already what the user asked for), and names passed through -More are applied, so they are reported neither way. $paths (game, cache, data, …) are still never touched.

inherited before after
VICTORY_RELAY=2 (script sets the same) silent silent
VICTORY_THIN=0 (script sets a different value) "Discarded inherited values for VICTORY_THIN" "Overrode inherited values for VICTORY_THIN with this script's settings"
VICTORY_SOMETHING=1 (script never sets it) "Discarded … VICTORY_SOMETHING" "Discarded … VICTORY_SOMETHING" (same sentence, now true)
same value plus -More silent silent

Testing

Exercised with the real launcher against the already-built target\diag\victory.exe and a non-PE -Exe, so victory run fails fast and the title never starts:

  • before: caller $LASTEXITCODE = 0; after: 1
  • working directory restored on exit (checked from a PowerShell.Exiting handler)
  • the four env cases in the table above, each in a clean inherited environment

Switch set, -Safe, -More, -Build, the $paths block and the early guards are unchanged. Nothing else in the tree is touched.

Not in this PR

-Safe still leaves most fast-path switches on (it unsets three), which is a design question rather than a bug; and the victory run exit-code contract (the CLI always exits 0 after printing the title's code) is a maintainer decision.

**@⁠Jackster** on GitHub · 2026-11-27 03:16 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/459) `Jackster:launcher/exit-code` → `a-publier` · +25 −7 · 1 files · 1 commits · open ## What Two defects in `scripts/play.ps1`, the launcher the README documents. **1. It swallowed the exit code.** The script ended with ```powershell try { & $victory run $Exe --execute } finally { Pop-Location } ``` so a failing run left the caller with 0 — a wrapper or CI job cannot tell "the game ran" from "the FSR DLL was missing". Measured with the same script shape: child exits 7, caller saw 0. Now the code is taken right after the call, `Pop-Location` still runs, and the script exits with it. Verified on this branch with the real launcher and a malformed-title file (never starts the title): the caller now sees 1 where it saw 0. A `$code = 1` default covers a failure that never reaches the child's code. **2. The "Discarded inherited values" message misreported.** The old comparison ran *after* the script had set its own values, so a name the script overrides with a different value was reported as discarded, and the message could not distinguish "dropped" from "replaced". Now the script snapshots the inherited values before removing them and reports two accurate things: - **Discarded** — removed, and this script does not set the name again: the actionable case for `-More`. - **Overridden** — this script sets it to a different value: a separate sentence, so the user knows their value was replaced rather than lost. A name the script sets to the same value is silent (it is already what the user asked for), and names passed through `-More` are applied, so they are reported neither way. `$paths` (game, cache, data, …) are still never touched. | inherited | before | after | |---|---|---| | `VICTORY_RELAY=2` (script sets the same) | silent | silent | | `VICTORY_THIN=0` (script sets a different value) | "Discarded inherited values for VICTORY_THIN" | "Overrode inherited values for VICTORY_THIN with this script's settings" | | `VICTORY_SOMETHING=1` (script never sets it) | "Discarded … VICTORY_SOMETHING" | "Discarded … VICTORY_SOMETHING" (same sentence, now true) | | same value plus `-More` | silent | silent | ## Testing Exercised with the real launcher against the already-built `target\diag\victory.exe` and a non-PE `-Exe`, so `victory run` fails fast and the title never starts: - before: caller `$LASTEXITCODE = 0`; after: `1` - working directory restored on exit (checked from a `PowerShell.Exiting` handler) - the four env cases in the table above, each in a clean inherited environment Switch set, `-Safe`, `-More`, `-Build`, the `$paths` block and the early guards are unchanged. Nothing else in the tree is touched. ## Not in this PR `-Safe` still leaves most fast-path switches on (it unsets three), which is a design question rather than a bug; and the `victory run` exit-code contract (the CLI always exits 0 after printing the title's code) is a maintainer decision.
play.ps1 ended with `try { & $victory run ... } finally { Pop-Location }`,
so a failing run left the caller with 0 and no wrapper could tell a run
that failed from one that played. Take the child's code right after the
call, restore the directory in the finally, and exit with it; a failure
that never reaches the child's code exits 1.

The "Discarded inherited values" message compared against the live
environment after the script had already set its own values, so a value
the script overrides with a different one was reported as discarded, and
a dropped value could not be told from a replaced one. Snapshot what was
inherited before removing it, then report removed-and-not-set-again as
discarded and set-to-another-value as overridden, in two sentences. A
name set to the same value, or passed through -More, is silent.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 03:17:30 +00:00
Author
Owner

@⁠lvndrpup on GitHub · 2026-11-27 04:41 UTC · original · reviewed

Checked on Windows 11 build 26300, Windows PowerShell 5.1. I ran the 4eb6cfd and ca8177b versions of scripts/play.ps1 against a stub target\release\victory.exe that prints the VICTORY_* values it gets and exits with a chosen code, each case in a fresh powershell.exe with only the listed value inherited.

case 4eb6cfd this PR
stub exits 7, powershell -File play.ps1 ... process exit 0 process exit 7
stub exits 0, -File 0 0
stub exits 7, & play.ps1 ... from a session, then $LASTEXITCODE 7 7
working folder after the script restored restored
inherited VICTORY_RELAY=2 (script sets the same) silent silent
inherited VICTORY_THIN=0 (script sets 1) Discarded inherited values for VICTORY_THIN Overrode inherited values for VICTORY_THIN with this script's settings
inherited VICTORY_SOMETHING=1 (script never sets it) Discarded ... VICTORY_SOMETHING same
inherited VICTORY_THIN=0 and -More @{VICTORY_THIN='0'} silent, child gets 0 silent, child gets 0

So the exit-code fix is for -File callers (a CI step, a shortcut, a wrapper script). Someone calling it with & from an open window already saw the code through $LASTEXITCODE, so the description's "caller saw 0" is true of -File only. The child got the same VICTORY_* values in every case with both versions.

Overlap: #398 adds a folder check a few lines above; the two merge cleanly.

**@⁠lvndrpup** on GitHub · 2026-11-27 04:41 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/459#pullrequestreview-6083571123) · **reviewed** Checked on Windows 11 build 26300, Windows PowerShell 5.1. I ran the `4eb6cfd` and `ca8177b` versions of `scripts/play.ps1` against a stub `target\release\victory.exe` that prints the `VICTORY_*` values it gets and exits with a chosen code, each case in a fresh `powershell.exe` with only the listed value inherited. | case | `4eb6cfd` | this PR | |---|---|---| | stub exits 7, `powershell -File play.ps1 ...` | process exit 0 | process exit 7 | | stub exits 0, `-File` | 0 | 0 | | stub exits 7, `& play.ps1 ...` from a session, then `$LASTEXITCODE` | 7 | 7 | | working folder after the script | restored | restored | | inherited `VICTORY_RELAY=2` (script sets the same) | silent | silent | | inherited `VICTORY_THIN=0` (script sets 1) | `Discarded inherited values for VICTORY_THIN` | `Overrode inherited values for VICTORY_THIN with this script's settings` | | inherited `VICTORY_SOMETHING=1` (script never sets it) | `Discarded ... VICTORY_SOMETHING` | same | | inherited `VICTORY_THIN=0` and `-More @{VICTORY_THIN='0'}` | silent, child gets 0 | silent, child gets 0 | So the exit-code fix is for `-File` callers (a CI step, a shortcut, a wrapper script). Someone calling it with `&` from an open window already saw the code through `$LASTEXITCODE`, so the description's "caller saw 0" is true of `-File` only. The child got the same `VICTORY_*` values in every case with both versions. Overlap: #398 adds a folder check a few lines above; the two merge cleanly.
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/459/head:github-bot/gh-459'
git switch 'github-bot/gh-459'

Merge

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