4.1 KiB
4.1 KiB
Changelog
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
Unreleased
v0.2.0 - 2026-11-10
This release renames the API and hides the parser types. To upgrade, replace interpolate.Interpolate(env, s) with interpolate.Expand(s, env), and rename the Get method of a custom Env to Lookup, or use interpolate.LookupFunc(os.LookupEnv).
Added
LookupFunc, an adapter that makes a function such asos.LookupEnvanEnv.UnsetVariableError, the error from${NAME?message},${NAME:?message}andWithNoUnset, withNameandMessagefields. The error text does not change.WithNoUnset, an option that makes a reference to an unset variable an error, the same asset -uin bash.
Changed
Interpolate(env, s)is nowExpand(s, env, opts...).Identifiersis nowVariables, and returns each name only once, in the order of first use.- The
Getmethod ofEnvis nowLookup. NewSliceEnv(slice)is nowNewListEnv(pairs...). UseNewListEnv(os.Environ()...)for a slice.
Removed
- The exported parser and expression types, such as
Parser,NewParser,Expression,ExpressionItem,Expansion, and the*Expansiontypes. UseExpandandVariables.
Fixed
- On Windows,
NewMapEnvwith keys that differ only in case, such asPathandPATH, gave a random result. The last key in sorted order now wins.
v0.1.0 - 2026-11-10
Added
${VAR:?message}: error ifVARis unset or empty (#2).${VAR+word}and${VAR:+word}: usewordifVARis set, or set and not empty.${#VAR}: the length of the value in characters.\}in the word of a brace expansion is a literal}, for example${CONFIG:-{"a":1\}}.- New expansion types:
RequiredNonEmptyExpansion,AlternateExpansion,AlternateNonEmptyExpansion, andLengthExpansion. - Brace expansions can be nested at most 1000 levels deep. Deeper input returns an error instead of exhausting the stack.
Changed
- Go 1.25 or later is required.
- A
$that is not followed by a letter,_, or{is literal text. Before, inputs such as$1,$,$5,$@,'^abc$', and${VAR:-$}returned an error. - Names follow POSIX:
[A-Za-z_][A-Za-z0-9_]*.$_VARand${_VAR}now expand. Non-ASCII letters are no longer part of a name, so$éis literal text,$FOOéexpandsFOO, and${é}is an error. ${VAR:+word}is the alternate value. Before, it was parsed as a substring with offset+word, so${VAR:+1}was the value after the first character.- Substring offsets and lengths count characters, not bytes.
- A negative substring offset before the start of the value gives an empty string, the same as bash. Before, it gave the whole value.
- A blank substring offset or length counts as 0, so
${VAR::2},${VAR:2:}, and${VAR: }work. Before, they returned an error. Identifiersincludes the names in the word of${VAR-word}and${VAR?word}, the same as${VAR:-word}.- Error messages start with a lowercase letter, and say "end of input" for unterminated expansions. An empty
${}givesempty expansion ${}, expected a variable name(#1). The$VAR: messageerrors from required expansions are unchanged.
Fixed
- Substrings with a length near the maximum
intvalue no longer panic. - Invalid UTF-8 bytes in the input are kept unchanged. Before, they became U+FFFD.
- Calling
Parseagain on the sameParserparses the input again. Before, it returned an empty expression.
v0.0.2
The last release before the changes above. See buildkite/interpolate for the history before the fork.