...
1# envsubst
2
3`envsubst` is a Go package for expanding variables in a string using `${var}` syntax.
4Includes support for bash string replacement functions.
5
6## Documentation
7
8[Documentation can be found on GoDoc][doc].
9
10## Supported Functions
11
12| __Expression__ | __Meaning__ |
13| ----------------- | -------------- |
14| `${var}` | Value of `$var`
15| `${#var}` | String length of `$var`
16| `${var^}` | Uppercase first character of `$var`
17| `${var^^}` | Uppercase all characters in `$var`
18| `${var,}` | Lowercase first character of `$var`
19| `${var,,}` | Lowercase all characters in `$var`
20| `${var:n}` | Offset `$var` `n` characters from start
21| `${var:n:len}` | Offset `$var` `n` characters with max length of `len`
22| `${var#pattern}` | Strip shortest `pattern` match from start
23| `${var##pattern}` | Strip longest `pattern` match from start
24| `${var%pattern}` | Strip shortest `pattern` match from end
25| `${var%%pattern}` | Strip longest `pattern` match from end
26| `${var-default` | If `$var` is not set, evaluate expression as `$default`
27| `${var:-default` | If `$var` is not set or is empty, evaluate expression as `$default`
28| `${var=default` | If `$var` is not set, evaluate expression as `$default`
29| `${var:=default` | If `$var` is not set or is empty, evaluate expression as `$default`
30| `${var/pattern/replacement}` | Replace as few `pattern` matches as possible with `replacement`
31| `${var//pattern/replacement}` | Replace as many `pattern` matches as possible with `replacement`
32| `${var/#pattern/replacement}` | Replace `pattern` match with `replacement` from `$var` start
33| `${var/%pattern/replacement}` | Replace `pattern` match with `replacement` from `$var` end
34
35For a deeper reference, see [bash-hackers](https://wiki.bash-hackers.org/syntax/pe#case_modification) or [gnu pattern matching](https://www.gnu.org/software/bash/manual/html_node/Pattern-Matching.html).
36
37## Unsupported Functions
38
39* `${var-default}`
40* `${var+default}`
41* `${var:?default}`
42* `${var:+default}`
43
44[doc]: http://godoc.org/github.com/drone/envsubst
View as plain text