Documentation ¶
Overview ¶
Package shell was forked from buildkit/frontend/dockerfile/shell in order to allow shelling-out. This package is distributed under the original file's license, The Apache License, which is defined under https://github.com/moby/buildkit/blob/7c3e9fdd48c867f48a07a80cde64cc2d578cb332/LICENSE
Index ¶
- Variables
- func BuildEnvs(env []string) map[string]string
- func BuildShellOutEnvs(shellOutEnvs []string) map[string]struct{}
- func EqualEnvKeys(from, to string) bool
- func IsValidEnvVarName(name string) bool
- type EvalShellOutFn
- type Lex
- func (s *Lex) ProcessWord(word string, env []string, shelloutEnvs []string) (string, error)
- func (s *Lex) ProcessWordWithMap(word string, env map[string]string, shelloutEnvs map[string]struct{}) (string, error)
- func (s *Lex) ProcessWords(word string, env []string, shelloutEnvs []string) ([]string, error)
- func (s *Lex) ProcessWordsWithMap(word string, env map[string]string, shelloutEnvs map[string]struct{}) ([]string, error)
Constants ¶
This section is empty.
Variables ¶
var ErrNoShellOut = errors.New("shelling out is not available")
ErrNoShellOut occurs when the EvalShellOutFn was not set
Functions ¶
func BuildShellOutEnvs ¶ added in v0.7.0
BuildShellOutEnvs takes a list of shellOutEnvs and converts it to a map
func EqualEnvKeys ¶
EqualEnvKeys compare two strings and returns true if they are equal. On Unix this comparison is case sensitive. On Windows this comparison is case insensitive.
func IsValidEnvVarName ¶ added in v0.7.0
IsValidEnvVarName returns true if env name is valid
Types ¶
type EvalShellOutFn ¶
EvalShellOutFn is a supplied callback function which is called whenever a shell-out command needs to be evaluated
type Lex ¶
type Lex struct { RawQuotes bool RawEscapes bool SkipProcessQuotes bool SkipUnsetEnv bool ShellOut EvalShellOutFn // contains filtered or unexported fields }
Lex performs shell word splitting and variable expansion.
Lex takes a string and an array of env variables and process all quotes (" and ') as well as $xxx and ${xxx} env variable tokens. Tries to mimic bash shell process. It doesn't support all flavors of ${xx:...} formats but new ones can be added by adding code to the "special ${} format processing" section
func (*Lex) ProcessWord ¶
ProcessWord will use the 'env' list of environment variables, and replace any env var references in 'word'.
func (*Lex) ProcessWordWithMap ¶
func (s *Lex) ProcessWordWithMap(word string, env map[string]string, shelloutEnvs map[string]struct{}) (string, error)
ProcessWordWithMap will use the 'env' list of environment variables, and replace any env var references in 'word'.
func (*Lex) ProcessWords ¶
ProcessWords will use the 'env' list of environment variables, and replace any env var references in 'word' then it will also return a slice of strings which represents the 'word' split up based on spaces - taking into account quotes. Note that this splitting is done **after** the env var substitutions are done. Note, each one is trimmed to remove leading and trailing spaces (unless they are quoted", but ProcessWord retains spaces between words.