Shell

public struct Shell

A type that can be used to launch bash commands

  • A type that holds information about the output of an executed bash command

    See more

    Declaration

    Swift

    public struct Result
  • Launches a shell command using bash

    Throws

    In case the command could not be run or the expected return code did not match the resulting one

    Declaration

    Swift

    @discardableResult
    public static func execute(
        _ command: String,
        expectedReturnCode: Int32? = nil,
        process: Process = .init(),
        outputHandle: FileHandle? = nil,
        errorHandle: FileHandle? = nil) throws -> Result

    Parameters

    command

    The command to run

    expectedReturnCode

    The expected return code

    process

    Which process to use to perform the command (default: A new one)

    outputHandle

    Any FileHandle that any output (STDOUT) should be redirected to (at the moment this is only supported on macOS)

    errorHandle

    Any FileHandle that any error output (STDERR) should be redirected to (at the moment this is only supported on macOS)

    Return Value

    The output, error output and return code of the running command

  • Launches a shell command using bash

    Throws

    In case the command could not be run or the expected return code did not match the resulting one

    Declaration

    Swift

    @discardableResult
    public static func execute(
        _ command: Command,
        expectedReturnCode: Int32? = nil,
        process: Process = .init(),
        outputHandle: FileHandle? = nil,
        errorHandle: FileHandle? = nil) throws -> Result

    Parameters

    command

    The ShellCommand instance that will be used to run the command

    expectedReturnCode

    The expected return code

    process

    Which process to use to perform the command (default: A new one)

    outputHandle

    Any FileHandle that any output (STDOUT) should be redirected to (at the moment this is only supported on macOS)

    errorHandle

    Any FileHandle that any error output (STDERR) should be redirected to (at the moment this is only supported on macOS)

    Return Value

    The output, error output and return code of the running command