package
0.0.0-20241213121623-605c1412b9b3
Repository: https://github.com/cilium/hive.git
Documentation: pkg.go.dev

# README

This is a fork of rsc.io/script (v0.0.2). It mostly adds support for interactive use to it.

The makeraw* files are adapted from term_unix.go etc. files from x/term to enable interrupts.

# Packages

Package scripttest adapts the script engine for use in tests.

# Functions

BoolCondition returns a Cond with the given truth value and summary.
No description provided by the author
CachedCondition is like Condition but only calls eval the first time the condition is evaluated for a given suffix.
Cat writes the concatenated contents of the named file(s) to the script's stdout buffer.
Cd changes the current working directory.
Chmod changes the permissions of a file or a directory..
Cmp compares the contents of two files, or the contents of either the "stdout" or "stderr" buffer and a file, returning a non-nil error if the contents differ.
Cmpenv is like Compare, but also performs environment substitutions on the contents of both arguments.
Command returns a new Cmd with a Usage method that returns a copy of the given CmdUsage and a Run method calls the given function.
Condition returns a Cond with the given summary and evaluation function.
Cp copies one or more files to a new location.
DefaultCmds returns a set of broadly useful script commands.
DefaultConds returns a set of broadly useful script conditions.
Echo writes its arguments to stdout, followed by a newline.
Env sets or logs the values of environment variables.
Exec runs an arbitrary executable as a subprocess.
Exists checks that the named file(s) exist.
Grep checks that file content matches a regexp.
Help writes command documentation to the script log.
MakeRaw sets the terminal to raw mode, but with interrupt signals enabled.
Mkdir creates a directory and any needed parent directories.
Mv renames an existing file or directory to a new path.
NewEngine returns an Engine configured with a basic set of commands and conditions.
NewState returns a new State permanently associated with ctx, with its initial working directory in workdir and its initial environment set to initialEnv (or os.Environ(), if initialEnv is nil).
OnceCondition returns a Cond that calls eval the first time the condition is evaluated.
PrefixCondition returns a Cond with the given summary and evaluation function.
Program returns a new command that runs the named program, found from the host process's PATH (not looked up in the script's PATH).
Replace replaces all occurrences of a string in a file with another string.
Rm removes a file or directory.
Sed implements a simple regexp replacement of text in a file.
Sleep sleeps for the given Go duration or until the script's context is cancelled, whichever happens first.
Stderr searches for a regular expression in the stderr buffer.
Stdout searches for a regular expression in the stdout buffer.
Stop returns a sentinel error that causes script execution to halt and s.Execute to return with a nil error.
Symlink creates a symbolic link.
Wait waits for the completion of background commands.

# Variables

ErrUnexpectedSuccess indicates that a script command that was expected to fail (as indicated by a "!" prefix) instead completed successfully.
ErrUsage may be returned by a Command to indicate that it was called with invalid arguments; its Usage method may be called to obtain details.

# Structs

A CmdUsage describes the usage of a Cmd, independent of its name (which can change based on its registration).
A CommandError describes an error resulting from attempting to execute a specific command.
A CondUsage describes the usage of a Cond, independent of its name (which can change based on its registration).
An Engine stores the configuration for executing a set of scripts.
A State encapsulates the current state of a running script engine, including the script environment and any running background commands.
A UsageError reports the valid arguments for a command.

# Interfaces

A Cmd is a command that is available to a script.
A Cond is a condition deciding whether a command should be run.

# Type aliases

A WaitFunc is a function called to retrieve the results of a Cmd.