File tree Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -422,7 +422,32 @@ public struct Environment: Sendable, Hashable {
422422 /// Keys with `nil` values in `newValue` will be removed from existing
423423 /// `Environment` before passing to child process.
424424 public func updating( _ newValue: [ Key : String ? ] ) -> Self {
425- return . init( config: . inherit( newValue) )
425+ switch config {
426+ case . inherit( var overrides) :
427+ for (key, value) in newValue {
428+ overrides [ key] = value
429+ }
430+ return . init( config: . inherit( overrides) )
431+ case . custom( var environment) :
432+ for (key, value) in newValue {
433+ environment [ key] = value
434+ }
435+ return . init( config: . custom( environment) )
436+ #if !os(Windows)
437+ case . rawBytes( var rawBytesArray) :
438+ let overriddenKeys = newValue. keys. map { Array ( " \( $0) = " . utf8) }
439+ rawBytesArray. removeAll {
440+ overriddenKeys. contains ( where: $0. starts)
441+ }
442+
443+ for (key, value) in newValue {
444+ if let value {
445+ rawBytesArray. append ( Array ( " \( key) = \( value) " . utf8) )
446+ }
447+ }
448+ return . init( config: . rawBytes( rawBytesArray) )
449+ #endif
450+ }
426451 }
427452 /// Use custom environment variables
428453 public static func custom( _ newValue: [ Key : String ] ) -> Self {
You can’t perform that action at this time.
0 commit comments