Repository navigation
Run a shell block until a cancellation token is cancelled - #51
Merged
Merged
Conversation
`ShellBuilder.Run(step, cancellationToken)` lets a host stop a block: cancelling the token stops the running command and starts no more. While the token can be cancelled, commands print through `Console.Out` and `Console.Error`, so a host that replaces those writers sees every line. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 12, 2026
Mpdreamz
added a commit
to nullean/argh
that referenced
this pull request
Nov 12, 2026
…rappers (#137) F# `sh` commands in a parallel stage now carry their target's name and stop when another target fails, and the generated wrappers list the new run switches. **Prompt summary:** Close the gaps the earlier PRs left. Breaking the wrapper output is fine. ## Why Proc.Fs ran a `target { }` block with a token that could not be cancelled, so its `sh` commands wrote to the shared console: no target name on their lines, and a failing sibling did not stop them. The mise include's `usage` spec did not list `--graph`, `-j`, `-k`, `--output` or `--skip`, so mise did not complete them. ## What #### F# `sh` in parallel stages While targets run side by side, `target { }` runs its block with the run's cancellation token through Proc.Fs's `ShellBuilder.Run(step, cancellationToken)`. Its commands then print through `Console.Out`, where each line gets the target's name, and cancelling stops the running command. A run without a parallel stage passes no token, so commands keep the console and its colours. Proc and Proc.Fs move to `0.22.0`. #### Wrapper switches The mise include lists the five switches. A build option with the same short name keeps it, as on the command line. **Breaking:** committed wrapper files change, so `__wrappers check` fails until `__wrappers sync` runs once. **Blocked:** this needs Proc and Proc.Fs `0.22.0`, which nullean/proc#51 adds. Restore fails until that is released. ## Verify ```bash dotnet test --project tests/Nullean.Make.Fs.Tests -c Release --treenode-filter "/*/*/*ParallelShellTests*/*" dotnet test --project tests/Nullean.Make.Tests -c Release --treenode-filter "/*/*/WrapperTests/*" ``` **Stack:** 6 of 6, on top of [#136](#136) 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ShellBuilder.Run(step, cancellationToken)runs ashell { }/steps { }block that its caller can stop. While the token can be cancelled, the block's commands print throughConsole.OutandConsole.Errorline by line.Prompt summary: Nullean.Make.Fs runs targets side by side, and needs to stop a target's
shcommands when another target fails, and to prefix each of their lines with the target's name. Proc.Fs keeps the token a block runs with internal, so a host has no way to do either.Why
ShellContext.Tokenis internal, andShellBuilder.Run(step)always runs withCancellationToken.None. A host that runs a block cannot cancel it, and with a token that cannot be cancelledRunner.runtakes theProc.Execpath, which writes to the shared console where a host that replacesConsole.Outnever sees the lines.What
A
Runoverload that takes a tokenShellBuilder.Run(step, cancellationToken)creates the block's context with that token.Run(step)calls it withCancellationToken.None, so ashell { }block behaves as before. Cancelling stops the running command and throwsOperationCanceledException; no command after it starts.Output through
Console.OutThis is what
Runner.runalready does for a token that can be cancelled; the README now says so, and that the output is then a pipe, so a tool that colours only for a terminal prints without colour.Verify
🤖 Generated with Claude Code