Skip to content

docs: a PowerShell script needs one more line, or a failed run reports success - #40

Merged
donislawdev merged 2 commits into
mainfrom
docs/powershell-exit-code
Sep 2, 2026
Merged

docs: a PowerShell script needs one more line, or a failed run reports success#40
donislawdev merged 2 commits into
mainfrom
docs/powershell-exit-code

Conversation

@donislawdev

Copy link
Copy Markdown
Owner

Found while building the pre-release ritual, and it is a fact about the people
who use this tool rather than about the tool.

Measured

Both Windows PowerShell 5.1 and pwsh 7, exit code read from the process rather
than from echo $?:

how it is run exit code
tfg --bad-flag directly 2
the same call inside a .ps1, run with -File 0
the same .ps1 ending with exit $LASTEXITCODE 2

A .ps1 does not inherit the exit code of the last program it ran. That is
PowerShell, not this tool - but .ps1 is the ordinary wrapper on Windows, and
this tool is built to be wired into CI. Somebody following the exit code table
in the README would get a green build on a run that refused the work, which is
the silent failure this project forbids everywhere else.

What changes

One subsection in the CI part of the README, with the line that fixes it. No
code changes - this cannot be fixed from our side, because the script's exit
code belongs to the shell.

cmd, bash and zsh need nothing extra, and the README says that too.

Recorded as O172, and the pre-release ritual already defends against it: every
.ps1 it generates ends with exit $LASTEXITCODE, or it would be measuring
PowerShell instead of the program.

🤖 Generated with Claude Code

donislawdev and others added 2 commits September 2, 2026 14:58
…s success

Measured on 2026-09-02, in both Windows PowerShell 5.1 and pwsh 7: tfg with a
bad flag returns 2 when it is run directly, and the same call wrapped in a .ps1
run with -File makes the script answer 0. Adding exit $LASTEXITCODE brings the
2 back.

That is PowerShell rather than this tool - a script does not inherit the exit
code of the last program it ran. But .ps1 is the ordinary wrapper on Windows,
and this tool is meant to be wired into CI, so a person following the exit code
table would get a green build on a run that refused the work.

The CI section now says so and shows the line. cmd, bash and zsh need nothing.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…recipe

Measured on 2026-09-02: a recipe kept in recipes/ with dir: out, run from
somewhere else, writes into out beside the caller rather than beside the
recipe. The behaviour has been the same since the beginning and was written
down nowhere, so the first person keeping recipes in their own directory had
to find it by looking for the files.

The key table now says it, with the way to pin it down.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@donislawdev
donislawdev merged commit 1da087f into main Sep 2, 2026
18 checks passed
@donislawdev
donislawdev deleted the docs/powershell-exit-code branch September 2, 2026 13:33
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.

1 participant