executil

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package executil holds tiny helpers shared by the exec runners.

Index

Constants

This section is empty.

Variables

View Source
var IsStdinTerminal = func() bool {
	fi, err := os.Stdin.Stat()
	if err != nil {
		return false
	}
	return fi.Mode()&os.ModeCharDevice != 0
}

IsStdinTerminal reports whether stdin is connected to a terminal. dotdrift uses it to decide whether a generated mise hook task may opt into interactive mode (interactive = true): when stdin is a TTY, an interactive command inside a hook (e.g. sudo) gets a controlling terminal so it can disable echo, instead of reading the password with echo on. Stdlib-only char-device check (golang.org/x/term is not vendored). A variable so tests and callers can substitute it.

Functions

func EchoCommand

func EchoCommand(w io.Writer, argv []string)

EchoCommand writes the set -x-style echo line "+ <argv>\n" to w.

func ShellJoin

func ShellJoin(argv []string) string

ShellJoin renders argv as a shell-style command line: elements are joined with single spaces; any element containing whitespace or a single quote is single-quoted (each ' escaped as '\”), bash set -x style. Simple elements pass through unquoted. Empty argv joins to the empty string.

Types

type LockedWriter added in v0.8.0

type LockedWriter struct {
	W io.Writer
	// contains filtered or unexported fields
}

LockedWriter serializes concurrent writes to W. os/exec spawns one copy goroutine per stream when Stdout and Stderr are different writers, so two MultiWriters capturing into one bytes.Buffer race (and silently lose writes) without it.

func (*LockedWriter) Write added in v0.8.0

func (l *LockedWriter) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

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