     
     let id = "test"
     
-    func createArguments(for call: String) throws -> [String] {
-        TestCommandExecutor.lastCall = call
-        return ["/bin/bash", "-c", call]
+    func execute(_ call: String, capture: Bool, matchers: [OutputMatcher]?) throws -> String? {
+        var captured = ""
+        let spawned = try Spawn(args: ["/bin/bash", "-c", call], output: { (output) in
+            if capture {
+                captured += output
+            } else {
+                print(output, terminator: "")
+            }
+            fflush(stdout)
+            matchers?.forEach { $0.match(output) }
+        })
+        
+        guard spawned.waitForExit() == 0 else {
+            throw TaskError.commandFailed
+        }
+        return capture ? captured : nil
     }
     
 }

//

import XCTest
@testable import Flock

class TestCommandExecutor: ServerCommandExecutor {

            ("testCapture", testCapture),
            ("testWithin", testWithin),
            ("testFileExists", testFileExists),
            ("testDirectoryExists", testDirectoryExists)
        ]
    }
    
