Skip to content

Scripts: smoke.ps1 leaves XCL_NETWORK=0 in the caller's session, and a -Game path ending in a backslash breaks the run #2259

Duplicate

Description

@itsonewi

Summary

Two small defects in the run block of scripts/smoke.ps1 (426a5a7). Neither changes the numbers in the block; both change what the machine does around it.

1. XCL_NETWORK=0 is left set in the caller's session

$env:XCL_NETWORK = '0'
$env:XCL_RUN_SECONDS = "$Seconds"
$env:XCL_ACTIVITY = '1'
$null = $p.Start()
...
Remove-Item Env:XCL_RUN_SECONDS, Env:XCL_ACTIVITY

Three variables are set, two are removed. A script runs in the caller's process, so XCL_NETWORK=0 stays in the PowerShell session after .\scripts\smoke.ps1 returns, and everything started from that window afterwards inherits it:

The same three variables also survive any throw before the Remove-Item line - XCL printed no log path is one - because nothing restores them on the way out. A try/finally around the run covers both cases: save the three values first, restore them in the block.

2. A -Game path ending in a backslash breaks the command line

$psi.FileName = $Xcl
$psi.Arguments = 'run "' + $Game + '"'

ProcessStartInfo.Arguments is one command-line string, so Windows parses it by its usual rules: a backslash directly before a quote does not escape anything, it makes that quote literal. So -Game 'D:\Games\Foo\' produces the command line run "D:\Games\Foo\", and XCL receives D:\Games\Foo" with no closing quote - a path error that says nothing about the real cause. The cmd.exe branch (/c ""<xcl>" run "<game>"") has the same hole.

This is not a hypothetical input shape: scripts/smoke-title.tests.ps1 already passes D:\Games\<name>\ with a trailing separator in its foreach ($game in @(...)) loop, but it asserts only the title: hash, so the command line built from that value is never exercised - the fixture is a .cmd that ignores its arguments.

Suggested fix

$Game = $Game.TrimEnd('\')

before the block that builds $psi, plus the save/restore above. Trimming the separator does not change the title: line, which hashes (Split-Path $Game -Leaf).Trim().

Not reported elsewhere

Searched open and closed issues for smoke.ps1, XCL_NETWORK, trailing backslash and command line escaping: nothing covers either point. #717 and #1855 are about what the block says; #1506 and #2213 are about how it is compared.

Not tested

  • No local run: this is read from 426a5a7 without a checkout, and both points are visible in the source. The -Game fix should be checked under both powershell.exe and pwsh.exe, since 5.1 and 7 pass the same string to CreateProcess.

AI use

  • Claude (Opus 5.5) read scripts/smoke.ps1, scripts/smoke-title.tests.ps1 and scripts/test-smoke-artifacts.tests.ps1 on 426a5a7, wrote this report and the two fixes; the human account checked each claim against the files before opening it.

Activity

  1. upipibi commented on Nov 25, 2026

    @upipibi
    Contributor

    @itsonewi Both of these already have open PRs, in case that saves a third one:

    1. XCL_NETWORK=0 left set: Scripts: preserve the calling shell environment after smoke runs #521 (wileyGray, 9bb6aa2, mergeable). It saves XCL_NETWORK, XCL_RUN_SECONDS and XCL_ACTIVITY before Start() and restores all three in a finally, so the caller's values come back, unset ones included.
    2. -Game ending in a backslash: Scripts: preserve trailing backslashes in smoke game paths #588 (luna020924, 1707802). It doubles the trailing backslashes before the closing quote ($Game -replace '\+\z', '$0$0'). It conflicts with main now, so it needs a rebase.

    I only read the two diffs against main 1a0bbe3a; I didn't run them.

    AI-assisted (Claude Code).

  2. itsonewi commented on Nov 25, 2026

    @itsonewi
    Author

    Thanks @upipibi - you are right, and both are open: I checked the two diffs against 1a0bbe3a and they cover the two halves of this report.

    How I missed them: my duplicate search used is:issue, which drops pull requests from the results, so both PRs were invisible to it. That is my mistake, not a judgement call.

    Closing this as a duplicate. The only thing worth keeping from it is the two fixes in one place: whoever lands first, the other's file and test do not overlap, so both can merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions