Structure
Shell
public struct Shell
A type that can be used to launch bash commands
Relationships
Nested Types
Shell.Result
A type that holds information about the output of an executed bash command
Methods
execute(_:expectedReturnCode:process:outputHandle:errorHandle:)
@discardableResult public static func execute(
_ command: String,
expectedReturnCode: Int32? = nil,
process: Process = .init(),
outputHandle: FileHandle? = nil,
errorHandle: FileHandle? = nil) throws -> Result
Launches a shell command using bash
Parameters
Name | Type | Description |
---|---|---|
command | String |
The command to run |
expectedReturnCode | Int32? |
The expected return code |
process | Process |
Which process to use to perform the command (default: A new one) |
outputHandle | FileHandle? |
Any |
errorHandle | FileHandle? |
Any |
Throws
In case the command could not be run or the expected return code did not match the resulting one
Returns
The output, error output and return code of the running command
execute(_:expectedReturnCode:process:outputHandle:errorHandle:)
@discardableResult public static func execute(
_ command: ShellCommand,
expectedReturnCode: Int32? = nil,
process: Process = .init(),
outputHandle: FileHandle? = nil,
errorHandle: FileHandle? = nil) throws -> Result
Launches a shell command using bash
Parameters
Name | Type | Description |
---|---|---|
command | ShellCommand |
The |
expectedReturnCode | Int32? |
The expected return code |
process | Process |
Which process to use to perform the command (default: A new one) |
outputHandle | FileHandle? |
Any |
errorHandle | FileHandle? |
Any |
Throws
In case the command could not be run or the expected return code did not match the resulting one
Returns
The output, error output and return code of the running command