Documentation
¶
Index ¶
- func ApplyEnv(cmd *exec.Cmd, env ...string)
- func Exec(shell string) (string, error)
- func ExecWithLog(ctx context.Context, shell string, logFile string) error
- func ExecWithStdinProgress(ctx context.Context, name string, args, env []string, stdin io.Reader, ...) (string, error)
- func Execf(shell string, args ...any) (string, error)
- func ExecfAsync(shell string, args ...any) error
- func ExecfWithContext(ctx context.Context, shell string, args ...any) (string, error)
- func ExecfWithDir(dir, shell string, args ...any) (string, error)
- func ExecfWithEnv(env []string, shell string, args ...any) (string, error)
- func ExecfWithOutput(shell string, args ...any) error
- func ExecfWithPipe(ctx context.Context, shell string, args ...any) (io.ReadCloser, error)
- func ExecfWithTTY(shell string, args ...any) (string, error)
- func ExecfWithTimeout(timeout time.Duration, shell string, args ...any) (string, error)
- func IsPTYError(err error) error
- type MessagePing
- type MessageResize
- type Turn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExecWithLog ¶
ExecWithLog 执行 shell 命令并将输出写入指定的日志文件 ctx 取消时会杀死整个进程组
func ExecWithStdinProgress ¶ added in v3.3.1
func ExecWithStdinProgress( ctx context.Context, name string, args, env []string, stdin io.Reader, total int64, interval time.Duration, progress func(written, total int64, rate float64), ) (string, error)
ExecWithStdinProgress 以外部命令消费 stdin,同时按周期通过 progress 回调输出进度
func ExecfWithContext ¶ added in v3.3.1
ExecfWithContext 安全执行 shell 命令,ctx 取消时终止进程
func ExecfWithDir ¶
ExecfWithDir 在指定目录下执行 shell 命令
func ExecfWithEnv ¶ added in v3.3.2
ExecfWithEnv 安全执行 shell 命令,环境变量仅注入子进程
func ExecfWithOutput ¶
ExecfWithOutput 执行 shell 命令并输出到终端
func ExecfWithPipe ¶
ExecfWithPipe 执行 shell 命令并返回管道
func ExecfWithTTY ¶
ExecfWithTTY 在伪终端下执行 shell 命令
func ExecfWithTimeout ¶
ExecfWithTimeout 执行 shell 命令并设置超时时间
func IsPTYError ¶
IsPTYError Linux kernel return EIO when attempting to read from a master pseudo terminal which no longer has an open slave. So ignore error here. See https://github.com/creack/pty/issues/21
Types ¶
type MessageResize ¶
type MessageResize struct {
Resize bool `json:"resize"`
Columns uint `json:"columns"`
Rows uint `json:"rows"`
}
MessageResize 终端大小调整消息
Click to show internal directories.
Click to hide internal directories.