ShellRunnable

Undocumented

  • run(_:_:file:line:) Extension method

    Shortcut for shell command, returns output and errors as a String.

    Warning

    will crash if ‘executable’ could not be launched.

    Declaration

    Swift

    public func run (executable: String, _ args: Any ..., file: String = #file, line: Int = #line) -> String

    Parameters

    executable

    path to an executable file.

    args

    the arguments, one string for each.

    Return Value

    standard output and standard error in one string, trimmed of whitespace and newline if it is single-line.

  • runAsync(_:_:file:line:) Extension method

    Run executable and return before it is finished.

    Warning

    will crash if ‘executable’ could not be launched.

    Declaration

    Swift

    public func runAsync (executable: String, _ args: Any ..., file: String = #file, line: Int = #line) -> AsyncShellTask

    Parameters

    executable

    Path to an executable file. If not then exit.

    args

    Arguments to the executable.

    Return Value

    An AsyncShellTask with standard output, standard error and a ‘finish’ function.

  • runAndPrint(_:_:) Extension method

    Run executable and print output and errors.

    Throws

    ShellError.ReturnedErrorCode (command: String, errorcode: Int32) if the exit code is anything but 0.

    ShellError.InAccessibleExecutable (path: String) if ‘executable’ turned out to be not so executable after all.

    Declaration

    Swift

    public func runAndPrint (executable: String, _ args: Any ...) throws

    Parameters

    executable

    path to an executable file.

    args

    arguments to the executable.

  • run(bash:file:line:) Extension method

    Shortcut for bash shell command, returns output and errors as a String.

    Declaration

    Swift

    public func run (bash bashcommand: String, file: String = #file, line: Int = #line) -> String

    Parameters

    bashcommand

    the bash shell command.

    Return Value

    standard output and standard error in one string, trimmed of whitespace and newline if it is single-line.

  • runAsync(bash:) Extension method

    Run bash command and return before it is finished.

    Declaration

    Swift

    public func runAsync (bash bashcommand: String) -> AsyncShellTask

    Parameters

    bashcommand

    the bash shell command.

    Return Value

    an AsyncShellTask struct with standard output, standard error and a ‘finish’ function.

  • runAndPrint(bash:) Extension method

    Run bash command and print output and errors.

    Throws

    a ShellError.ReturnedErrorCode if the return code is anything but 0.

    Declaration

    Swift

    public func runAndPrint (bash bashcommand: String) throws

    Parameters

    bashcommand

    the bash shell command.