Tags: bitfield/script
Tags
Add Shell method for running commands via the system shell (#245) * Add Shell method for running commands via the system shell Adds ExecCommand(name, args...), which runs a command directly with no parsing, holding the shared stdin/stdout/stderr/env/context/ error-handling logic. Exec is now a thin wrapper that splits cmdLine with shell.Fields and delegates to ExecCommand. A shell.Fields parse error is now surfaced immediately via p.WithError, rather than only becoming visible once the pipe is read; this is covered by TestExec_SetsErrorImmediatelyOnInvalidCommandLineSyntax. Shell runs cmdLine via the operating system's native shell (sh -c on Unix-like systems, cmd /C on Windows, chosen via runtime.GOOS), by calling ExecCommand directly with cmdLine as a single, completely unmodified argument. This fixes the WithEnv/variable-expansion bug described in #239, since the shell alone is responsible for parsing and expansion, with no local re-interpretation of the command line. Tested on both Linux and Windows. * tweaks * bump to go1.26.6 for GO-2026-6218, GO-2026-6090, GO-2026-5972, GO-2026-5856, GO-2026-5026 --------- Co-authored-by: Dhanalakshmi-D04 <dhanalakshmidgowda04@gmail.com> Co-authored-by: John Arundel <john@bitfieldconsulting.com>
Lowered go.mod to 1.25.0 (#242) * Lowered go.mod to 1.25.0 This restores support for consumers still using Go 1.25. The previous bump to `go 1.26.4` forced all consumers of this library to use Go 1.26 or newer. The codebase does not use any Go 1.26-specific features, making the `1.26` language requirement unnecessary. `go1.25.11` contains the same critical security patches as `go1.26.4` (fixing vulnerabilities in `crypto/x509`, `net/textproto`, and `mime`). Go's toolchain auto-switching (introduced in Go 1.21) will automatically download and use `go1.25.11` for developers working on this module if their local toolchain is older, ensuring they build with the secure version without forcing a major Go upgrade. * Changed toolchain to 1.26.4 This makes govulncheck work even for users with go1.26.{0-3}
Update First(n int) to read no more data than necessary (#199) First(N) now closes its output after it has read N lines, terminating the pipe without consuming unnecessary further input (apart from the 4KiB scanner buffer). Co-authored-by: John Arundel <john@bitfieldconsulting.com>
PreviousNext