# \[Second Review\] SF-0037: Subprocess 1.0

**URL:** <https://forums.swift.org/t/second-review-sf-0037-subprocess-1-0/88199>\
**Category:** Foundation\
**Created:** [July 10, 2026, 5:46pm UTC](https://forums.swift.org/t/second-review-sf-0037-subprocess-1-0/88199 "2026-07-10T17:46:00Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![tinaliu](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/tinaliu/32/20927_2.png) [@tinaliu](https://forums.swift.org/u/tinaliu)\
**Post date:** [July 10, 2026, 5:46pm UTC](https://forums.swift.org/t/second-review-sf-0037-subprocess-1-0/88199/1 "2026-07-10T17:46:00Z")

</div>

Hello Swift community,

Thank you for your participation in [the first review](https://forums.swift.org/t/review-sf-0037-subprocess-1-0/86004). We are seeking another round of feedback on [Subprocess 1.0 Update](https://github.com/swiftlang/swift-foundation/blob/main/Proposals/0037-subprocess-1.0.md) through 2026-07-17.

Charles has updated the proposal after reviewing community feedback. As with the first review, I'd like to focus specifically on these changes rather than revisiting the design discussions from beta.

All feedback should be either on this forum thread or, if you would like to keep your feedback private, directly to me as the review manager by DM. When contacting the review manager directly, please include the proposal name in the subject line.

##### **Things to consider**

The goal of this feedback period is to improve the proposal through constructive discussion. Here are some questions to consider in your feedback:

- How much effort did you put into your evaluation of this proposal?
- If you have used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?

More information about Swift-Foundation evolution process is available at

> [swift-foundation/CONTRIBUTING.md at main · swiftlang/swift-foundation · GitHub](https://github.com/swiftlang/swift-foundation/blob/main/CONTRIBUTING.md)

And if you like this proposal, please don't be shy to express your positive support, with a heart or a word of encouragement.

Thank you,  
Tina, Review Manager

---

<div class="post-metadata">

**Author:** ![johannesweiss](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/johannesweiss/32/38183_2.png) [@johannesweiss](https://forums.swift.org/u/johannesweiss)\
**Post date:** [July 11, 2026, 10:10am UTC](https://forums.swift.org/t/second-review-sf-0037-subprocess-1-0/88199/2 "2026-07-11T10:10:49Z")

</div>

> The goal of this feedback period is to improve the proposal through constructive discussion.

The proposal could be improved by moving the set of global `run()` functions onto a type.

Currently, we still have a global `run()` function which

- Contradicts Swift API design
- Makes some forms of testing unnecessarily hard
- Is unmotivated
- Is hard to read. Even Subprocess's _own codebase_ seems to prefer to essentially always write `Subprocess.run(...)` which is of course nicer. So let's do that.
- We still have _six_ `public func run`s which are overloads. Normally, overloads are just a source of friction and odd problems with completion.
  - In this case however it makes dependency injection without wrapping the Subprocess module into a type:
    - You can pass a type that has six member functions called `run`
    - You can (awkwardly) pass a single global function `run`
    - You _cannot_ pass around a bundle of six global `run` functions without bundling them into your own type. Let's have just one type for that and call it `public struct|enum|whatever Subprocess`

(I do very much disregard all 'having a global `run()` function makes Swift nice for shell script replacements'. This is not real, it doesn't look nearly as clean as a simple shell script and that also shouldn't be the goal. But if you really want that, you can make a `SubprocessGlobal` module that just defines a global function/variable called `runSubprocess` or `run` and forward)

---

<div class="post-metadata">

**Author:** ![OneSadCookie](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/onesadcookie/32/3205_2.png) [@OneSadCookie](https://forums.swift.org/u/OneSadCookie)\
**Post date:** [July 11, 2026, 12:22pm UTC](https://forums.swift.org/t/second-review-sf-0037-subprocess-1-0/88199/3 "2026-07-11T12:22:40Z")

</div>

It's hard to get a feel for the proposed changes without actually using them, so I won't comment on those.

I will say that in my usage of the 0.4-0.5 subprocess releases, I've had two problems which _aren't_ addressed by the 1.0 proposal:

- global `run`. I always want to call it as `Subprocess.run` because just `run` is so vague (and quite foreign to Swift, which has very few global functions). I agree with many of the previous comments in this and the previous 1.0 review thread: let's put `run` as a static in an empty `Subprocess` type.
- too many overloads: basically it means that in any nested code (task groups, closures, etc.) _any_ mistake in the arguments to `run` results in a generic error (failure to typecheck in a reasonable time, or an error misattributed to one of the enclosing functions). I know Swift tends to shy away from builders, because the flexibility of default arguments and ad-hoc overloading makes them less necessary than some other languages, but I think it could be worth reconsidering here.

---

<div class="post-metadata">

**Author:** ![tinaliu](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/tinaliu/32/20927_2.png) [@tinaliu](https://forums.swift.org/u/tinaliu)\
**Post date:** [July 13, 2026, 10:55pm UTC](https://forums.swift.org/t/second-review-sf-0037-subprocess-1-0/88199/4 "2026-07-13T22:55:57Z")

</div>

Thanks for trying the previous versions. One of the changes in this proposal was about reducing the number of overloads. So if you get a chance please check it out

Also, reviewer manager hat off, I also wanted to chime in that I also write `Subprocess.run`, but it doesn't bother me that this is not enforced by the package. Also, putting a static func inside a scope, say a `enum`, still doesn't allow mocking for testing since it is effectively a global function. So, what problems does putting it inside a scope fix exactly?

---

<div class="post-metadata">

**Author:** ![j-f1](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/j-f1/32/12287_2.png) [@j-f1](https://forums.swift.org/u/j-f1)\
**Post date:** [July 13, 2026, 11:58pm UTC](https://forums.swift.org/t/second-review-sf-0037-subprocess-1-0/88199/5 "2026-07-13T23:58:25Z")

</div>

> [@tinaliu](#):
>
> Also, putting a static func inside a scope, say a `enum`, still doesn't allow mocking for testing since it is effectively a global function. So, what problems does putting it inside a scope fix exactly?

You could do `extension Subprocess: MyMockProtocol` and then accept `some MyMockProtocol.Type` instead of directly referencing `Subprocess`. But modules cannot conform to protocols.

---

<div class="post-metadata">

**Author:** ![icharleshu](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/icharleshu/32/20905_2.png) [@icharleshu](https://forums.swift.org/u/icharleshu)\
**Post date:** [July 14, 2026, 12:06am UTC](https://forums.swift.org/t/second-review-sf-0037-subprocess-1-0/88199/6 "2026-07-14T00:06:31Z")

</div>

> [@johannesweiss](#):
>
> - Is hard to read. Even Subprocess's _own codebase_ seems to prefer to essentially always write `Subprocess.run(...)` which is of course nicer. So let's do that.

> [@OneSadCookie](#):
>
> - I always want to call it as `Subprocess.run` because just `run` is so vague (and quite foreign to Swift, which has very few global functions).

There's nothing stopping you from writing `Subprocess.run`, as demonstrated by subprocess’s own testing code. You can always write that if that's what you prefer, so why force everyone to write that when they don't have to?

> [@johannesweiss](#):
>
> (I do very much disregard all 'having a global `run()` function makes Swift nice for shell script replacements'.

This is not true. We never said we wanted global `run()` functions because we "want scripting to look nicer" (that was the argument for having `Executable.path` for convenience path lookup). We decided to use global functions because:

- `Subprocess` has a very small and focused purpose: to launch processes with one of the `run()` functions. We started with `Subprocess` type and eventually decided to remove it when it became an empty wrapper just to hold `static func run()` with no instance method, no property, and no initializer. We don't see any benefit in having an empty namespace wrapper.
- `Subprocess` is NOT in Foundation nor the Standard Library. You do not "accidentally" get these `run()` functions because someone else imported `Foundation` nor do you have these `run()` functions "polluting" the global namespace like global functions from the standard library, such as `print`.
- You can absolutely write `Subprocess.run` if you prefer since the module acts like a perfectly fine namespace on its own already.

So far I have not received a convincing technical counterargument around why the points given above are invalid. We've also been [using Subprocess ourselves](https://github.com/swiftlang/swift-foundation-icu/tree/main/ICUExport) and did not find global `run()` functions to be an issue so far. Most arguments against global `run()` function centered around "this is different from usual Swift API design". While I agree with this sentiment, I believe we've given enough technical argument on why we made this "exception".

> [@johannesweiss](#):
>
> - In this case however it makes dependency injection without wrapping the Subprocess module into a type:

I still maintain the same opinion from the [previous review thread](https://forums.swift.org/t/review-sf-0037-subprocess-1-0/86004/4):

> However, I do not believe it is Subprocess's responsibility to solve that problem. Subprocess has a single, well-scoped job: providing the primitives needed to spawn child processes. It is the client's responsibility to wrap those primitives in whatever abstraction they see fit, asuch as protocol, wrapper type, etc., that suits their testing strategy. This is no different from how consumers of FileManager routinely introduce their own protocol for testing purposes; we would not expect FileManager itself to be a protocol just to accommodate that pattern.

The downstream client should perform wrapping and dependency injection in a way that fits their needs. For example, most clients only use one or two `run()` functions from Subprocess, so they would only need to wrap the ones they need instead of all six. [Swiftly](https://github.com/swiftlang/swiftly/blob/d0795a223706ab274c0f361be38a5cef14c8d296/Sources/SwiftlyCore/ModeledCommandLine.swift#L25) is a great example: it makes extensive use of Subprocess, but it's all funneled through one `run()`.

> [@OneSadCookie](#):
>
> - too many overloads: basically it means that in any nested code (task groups, closures, etc.) _any_ mistake in the arguments to `run` results in a generic error

This was one of the feedback items we received from the first review, and it has been addressed in 1.0.0-beta.1. Please see [this section of the proposal](https://github.com/swiftlang/swift-foundation/blob/main/Proposals/0037-subprocess-1.0.md#collapse-the-run-overloads-behind-a-generic-execution-type).

---

<div class="post-metadata">

**Author:** ![tinaliu](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/tinaliu/32/20927_2.png) [@tinaliu](https://forums.swift.org/u/tinaliu)\
**Post date:** [August 4, 2026, 12:21am UTC](https://forums.swift.org/t/second-review-sf-0037-subprocess-1-0/88199/7 "2026-08-04T00:21:59Z")

</div>

Thank you to everyone who participated in the second review of SF-0037: Subprocess 1.0.

After discussion among workgroup members, we have decided to accept this proposal. Two topics that repeatedly came up in the discussions are the global run functions and the number of overloads.

- On the `static` `run` function: The workgroup doesn't think converting the global `run` functions to static functions on a type would meaningfully improve the API design.

- On the number of API overloads: Charles has already made significant progress in this area, reducing the overload count from 16 in earlier versions to 6 in the current proposal. The remaining Span-specific overloads serve as a necessary workaround for the current lack of support for capturing `~Copyable` and `~Escapable` types in closures. Once the compiler support is in place, we can revisit these and deprecate them if feasible.

We decided to accept it as 1.0 since there are no open questions or pending actions.  
We expect that we will keep evolving the package, so there will always be opportunities to refine the API after this proposal is accepted.

Thank you all,  
Tina, review manager
