-
Notifications
You must be signed in to change notification settings - Fork 45
Closed
Description
Describe the bug
When using the instance function Environment.updating(_:) on any existing instance of Environment, Subprocess simply adds the new values to the .inherit environment rather than the instance itself.
To Reproduce
Consider this program that uses a .custom environment and the env command to print the subprocess' perceived environment:
let pristineEnv: Environment = .custom(["A": "1"])
let result1 = try await run(
.name("env"),
environment: pristineEnv,
output: .string(limit: 4096)
)
// Print 1
print(result1.standardOutput ?? "")
let result2 = try await run(
.name("env"),
environment: pristineEnv.updating(["B": "2"]),
output: .string(limit: 4096)
)
// Print 2
print(result2.standardOutput ?? "")Expected behavior
- At Print 1
- ✅ The printed environment is exactly "A=1\n"
- This is expected as the environment is
.custom(i.e. not.inherited from the calling process)
- This is expected as the environment is
- ✅ The printed environment is exactly "A=1\n"
- At Print 2
- ✅ The printed environment includes "B=2"
- ❌ The printed environment does not include "A=1"
- ❌ The printed environment includes the entire inherited environment (e.g.
USER,HOMEetc)
Environment:
- macOS 15.6
- swiftlang-6.1.0.110.21 clang-1700.0.13.3
Additional context
This report is based on my assumption about how the .updating function should work based on it's name, apologies if this behaviour is intended.
a7medev
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working