Skip to content

Commit 5d36391

Browse files
committed
Fix trivial compilation errors on older Swift versions
1 parent 340a394 commit 5d36391

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

Sources/ProcessInvocation/ProcessInvocation.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ public struct ProcessInvocation : AsyncSequence {
600600
} else {
601601
let execBasePath = getenv(Constants.bridgePathEnvVarName).flatMap{ FilePath(String(cString: $0)) }
602602
if !usePATH {
603-
guard let execBasePath else {
603+
guard let execBasePath = execBasePath else {
604604
Conf.logger?.error("Cannot launch process and send its fd if \(Constants.bridgePathEnvVarName) is not set.")
605605
try cleanupAndThrow(Err.bridgePathEnvVarNotSet)
606606
}
@@ -695,7 +695,7 @@ public struct ProcessInvocation : AsyncSequence {
695695

696696
let additionalTerminationHandler: @Sendable (Process) -> Void = { _ in
697697
Conf.logger?.debug("Called in termination handler of process.")
698-
if let fdWhoseFgPgIDShouldBeSet {
698+
if let fdWhoseFgPgIDShouldBeSet = fdWhoseFgPgIDShouldBeSet {
699699
/* Let’s revert the fg pg ID back to our pg ID. */
700700
if tcsetpgrp(fdWhoseFgPgIDShouldBeSet.rawValue, getpgrp()) != 0 && errno != ENOTTY {
701701
Conf.logger?.error("Failed setting foreground process group ID of controlling terminal of stdin back to our process group.")
@@ -789,7 +789,7 @@ public struct ProcessInvocation : AsyncSequence {
789789
/* The executable is now launched.
790790
* We must not fail after this, so we wrap the rest of the function in a non-throwing block. */
791791
return {
792-
if let fdWhoseFgPgIDShouldBeSet {
792+
if let fdWhoseFgPgIDShouldBeSet = fdWhoseFgPgIDShouldBeSet {
793793
if tcsetpgrp(fdWhoseFgPgIDShouldBeSet.rawValue, getpgid(p.processIdentifier)) != 0 && errno != ENOTTY {
794794
Conf.logger?.error("Failed setting the foreground group ID to the child process group ID.", metadata: ["error": "\(Errno(rawValue: errno))"])
795795
}

Sources/ProcessInvocationBridge/ProcessInvocationBridge.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,11 @@ struct ProcessInvocationBridge : ParsableCommand {
213213
let controlBufSize = 256
214214
let controlBuf = UnsafeMutablePointer<Int8>.allocate(capacity: controlBufSize)
215215
defer {controlBuf.deallocate()}
216+
#if swift(>=5.8)
216217
controlBuf.update(repeating: 0, count: controlBufSize)
218+
#else
219+
controlBuf.assign(repeating: 0, count: controlBufSize)
220+
#endif
217221
msg.msg_control = UnsafeMutableRawPointer(controlBuf)
218222
#if canImport(Darwin)
219223
msg.msg_controllen = socklen_t(controlBufSize)

0 commit comments

Comments
 (0)