@@ -102,7 +102,7 @@ extension SubprocessUnixTests {
102102extension SubprocessUnixTests {
103103 @Test func testArgumentsArrayLiteral( ) async throws {
104104 let result = try await Subprocess . run (
105- . path( " /bin/bash " ) ,
105+ . path( " /bin/sh " ) ,
106106 arguments: [ " -c " , " echo Hello World! " ] ,
107107 output: . string
108108 )
@@ -117,7 +117,7 @@ extension SubprocessUnixTests {
117117
118118 @Test func testArgumentsOverride( ) async throws {
119119 let result = try await Subprocess . run (
120- . path( " /bin/bash " ) ,
120+ . path( " /bin/sh " ) ,
121121 arguments: . init(
122122 executablePathOverride: " apple " ,
123123 remainingValues: [ " -c " , " echo $0 " ]
@@ -157,7 +157,7 @@ extension SubprocessUnixTests {
157157extension SubprocessUnixTests {
158158 @Test func testEnvironmentInherit( ) async throws {
159159 let result = try await Subprocess . run (
160- . path( " /bin/bash " ) ,
160+ . path( " /bin/sh " ) ,
161161 arguments: [ " -c " , " printenv PATH " ] ,
162162 environment: . inherit,
163163 output: . string
@@ -173,7 +173,7 @@ extension SubprocessUnixTests {
173173
174174 @Test func testEnvironmentInheritOverride( ) async throws {
175175 let result = try await Subprocess . run (
176- . path( " /bin/bash " ) ,
176+ . path( " /bin/sh " ) ,
177177 arguments: [ " -c " , " printenv HOME " ] ,
178178 environment: . inherit. updating ( [
179179 " HOME " : " /my/new/home "
@@ -595,7 +595,7 @@ extension SubprocessUnixTests {
595595 contentsOf: URL ( filePath: theMysteriousIsland. string)
596596 )
597597 let catResult = try await Subprocess . run (
598- . path( " /bin/bash " ) ,
598+ . path( " /bin/sh " ) ,
599599 arguments: [ " -c " , " cat \( theMysteriousIsland. string) 1>&2 " ] ,
600600 error: . data( limit: 2048 * 1024 )
601601 )
@@ -668,11 +668,14 @@ extension SubprocessUnixTests {
668668 var platformOptions = PlatformOptions ( )
669669 platformOptions. supplementaryGroups = Array ( expectedGroups)
670670 let idResult = try await Subprocess . run (
671- . path ( " /usr/bin/ swift" ) ,
671+ . name ( " swift " ) ,
672672 arguments: [ getgroupsSwift. string] ,
673673 platformOptions: platformOptions,
674- output: . string
674+ output: . string,
675+ error: . string,
675676 )
677+ let error = try #require( idResult. standardError)
678+ try #require( error == " " )
676679 #expect( idResult. terminationStatus. isSuccess)
677680 let ids = try #require(
678681 idResult. standardOutput
@@ -696,7 +699,7 @@ extension SubprocessUnixTests {
696699 // Sets the process group ID to 0, which creates a new session
697700 platformOptions. processGroupID = 0
698701 let psResult = try await Subprocess . run (
699- . path( " /bin/bash " ) ,
702+ . path( " /bin/sh " ) ,
700703 arguments: [ " -c " , " ps -o pid,pgid -p $$ " ] ,
701704 platformOptions: platformOptions,
702705 output: . string
@@ -723,22 +726,22 @@ extension SubprocessUnixTests {
723726 // Check the process ID (pid), process group ID (pgid), and
724727 // controlling terminal's process group ID (tpgid)
725728 let psResult = try await Subprocess . run (
726- . path( " /bin/bash " ) ,
729+ . path( " /bin/sh " ) ,
727730 arguments: [ " -c " , " ps -o pid,pgid,tpgid -p $$ " ] ,
728731 platformOptions: platformOptions,
729732 output: . string
730733 )
731734 try assertNewSessionCreated ( with: psResult)
732735 }
733736
734- @Test func testTeardownSequence( ) async throws {
737+ @Test ( . requiresBash ) func testTeardownSequence( ) async throws {
735738 let result = try await Subprocess . run (
736- . path ( " /bin/ bash" ) ,
739+ . name ( " bash " ) ,
737740 arguments: [
738741 " -c " ,
739742 """
740743 set -e
741- trap 'echo saw SIGQUIT;' SIGQUIT
744+ trap 'echo saw SIGQUIT;' QUIT
742745 trap 'echo saw SIGTERM;' TERM
743746 trap 'echo saw SIGINT; exit 42;' INT
744747 while true; do sleep 1; done
@@ -777,7 +780,7 @@ extension SubprocessUnixTests {
777780 @Test func testRunDetached( ) async throws {
778781 let ( readFd, writeFd) = try FileDescriptor . pipe ( )
779782 let pid = try runDetached (
780- . path( " /bin/bash " ) ,
783+ . path( " /bin/sh " ) ,
781784 arguments: [ " -c " , " echo $$ " ] ,
782785 output: writeFd
783786 )
@@ -1046,11 +1049,11 @@ extension FileDescriptor {
10461049
10471050// MARK: - Performance Tests
10481051extension SubprocessUnixTests {
1049- @Test func testConcurrentRun( ) async throws {
1052+ @Test ( . requiresBash ) func testConcurrentRun( ) async throws {
10501053 // Launch as many processes as we can
10511054 // Figure out the max open file limit
10521055 let limitResult = try await Subprocess . run (
1053- . path( " /bin/bash " ) ,
1056+ . path( " /bin/sh " ) ,
10541057 arguments: [ " -c " , " ulimit -n " ] ,
10551058 output: . string
10561059 )
@@ -1075,8 +1078,9 @@ extension SubprocessUnixTests {
10751078 let byteCount = 1000
10761079 for _ in 0 ..< maxConcurrent {
10771080 group. addTask {
1081+ // This invocation specifically requires bash semantics; sh (on FreeBSD at least) does not consistently support -s in this way
10781082 let r = try await Subprocess . run (
1079- . path ( " /bin/ bash" ) ,
1083+ . name ( " bash " ) ,
10801084 arguments: [
10811085 " -sc " , #"echo "$1" && echo "$1" >&2"# , " -- " , String ( repeating: " X " , count: byteCount) ,
10821086 ] ,
@@ -1099,13 +1103,14 @@ extension SubprocessUnixTests {
10991103 }
11001104 }
11011105
1102- @Test func testCaptureLongStandardOutputAndError( ) async throws {
1106+ @Test ( . requiresBash ) func testCaptureLongStandardOutputAndError( ) async throws {
11031107 try await withThrowingTaskGroup ( of: Void . self) { group in
11041108 var running = 0
11051109 for _ in 0 ..< 10 {
11061110 group. addTask {
1111+ // This invocation specifically requires bash semantics; sh (on FreeBSD at least) does not consistently support -s in this way
11071112 let r = try await Subprocess . run (
1108- . path ( " /bin/ bash" ) ,
1113+ . name ( " bash " ) ,
11091114 arguments: [
11101115 " -sc " , #"echo "$1" && echo "$1" >&2"# , " -- " , String ( repeating: " X " , count: 100_000 ) ,
11111116 ] ,
0 commit comments