subprocess

package
v3.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 7, 2024 License: BSD-3-Clause, MIT Imports: 13 Imported by: 0

Documentation

Overview

Package subprocess provides helper functions for forking new processes NOTE: Subject to change, do not rely on this package from outside git-lfs source

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatForShell

func FormatForShell(name string, args string) (string, []string)

FormatForShell takes a command name and an argument string and returns a command and arguments that pass this command to the shell. Note that neither the command nor the arguments are quoted. Consider FormatForShellQuoted instead.

func FormatForShellQuotedArgs

func FormatForShellQuotedArgs(name string, args []string) (string, []string)

FormatForShellQuotedArgs takes a command name and an argument string and returns a command and arguments that pass this command to the shell. The arguments are escaped, but the name of the command is not.

func FormatPercentSequences added in v3.2.0

func FormatPercentSequences(pattern string, replacements map[string]string) string

func LookPath

func LookPath(file string) (string, error)

LookPath searches for an executable named file in the directories named by the PATH environment variable. If file contains a slash, it is tried directly and the PATH is not consulted. The result may be an absolute path or a path relative to the current directory.

func Output

func Output(cmd *Cmd) (string, error)

func ResetEnvironment

func ResetEnvironment()

ResetEnvironment resets the cached environment that's used in subprocess calls.

func ShellQuote

func ShellQuote(strs []string) []string

ShellQuote returns a copied string slice where each element is quoted suitably for sh.

func ShellQuoteSingle

func ShellQuoteSingle(str string) string

ShellQuoteSingle returns a string which is quoted suitably for sh.

func SimpleExec

func SimpleExec(name string, args ...string) (string, error)

SimpleExec is a small wrapper around os/exec.Command.

func Trace

func Trace(name string, args ...string)

Types

type BufferedCmd

type BufferedCmd struct {
	*Cmd

	Stdin  io.WriteCloser
	Stdout *bufio.Reader
	Stderr *bufio.Reader
}

func BufferedExec

func BufferedExec(name string, args ...string) (*BufferedCmd, error)

BufferedExec starts up a command and creates a stdin pipe and a buffered stdout & stderr pipes, wrapped in a BufferedCmd. The stdout buffer will be of stdoutBufSize bytes.

type Cmd

type Cmd struct {
	*exec.Cmd
	// contains filtered or unexported fields
}

Thin wrapper around exec.Cmd. Takes care of pipe shutdown by keeping an internal reference to any created pipes. Whenever Cmd.Wait() is called, all created pipes are closed.

func ExecCommand

func ExecCommand(name string, arg ...string) (*Cmd, error)

ExecCommand is a small platform specific wrapper around os/exec.Command

func (*Cmd) CombinedOutput

func (c *Cmd) CombinedOutput() ([]byte, error)

func (*Cmd) Output

func (c *Cmd) Output() ([]byte, error)

func (*Cmd) Run

func (c *Cmd) Run() error

func (*Cmd) Start

func (c *Cmd) Start() error

func (*Cmd) StderrPipe

func (c *Cmd) StderrPipe() (io.ReadCloser, error)

func (*Cmd) StdinPipe

func (c *Cmd) StdinPipe() (io.WriteCloser, error)

func (*Cmd) StdoutPipe

func (c *Cmd) StdoutPipe() (io.ReadCloser, error)

func (*Cmd) Wait

func (c *Cmd) Wait() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL