Skip to content

r1b/envsubst

Repository files navigation

envsubst

Clone of envsubst. Supports parameter expansion.

usage

envsubst-cli [VARIABLE] ... < INPUT > OUTPUT

semantics

I try to be true to the semantics of the original envsubst which are slightly different from the semantics in a shell. These differences include:

  • Most "bad substitutions" are allowed
    • ${} -> ${}
    • ${{foo} -> ${{foo}
  • Nested expansions are allowed:
    • export foo=bar ${${foo}} -> ${bar}
    • ...but they only expand at depth=1 ;p

Differences from the original envsubst include:

  • Shell builtin variables like $$ and $0 are not supported
  • Unset variables throw an error by default (use ${parameter-} or ${parameter+} to ignore unset variables)
  • Instead of using SHELL-FORMAT whitelisted variable names are passed as arguments

parameter expansion

The following expansions are supported:

form set and not null set but null unset
${parameter:-word} substitute parameter substitute word substitute word
${parameter-word} substitute parameter substitute null substitute word
${parameter:?[word]} substitute parameter error, exit error, exit
${parameter?[word]} substitute parameter substitute null error, exit
${parameter:+word} substitute word substitute null substitute null
${parameter+word} substitute word substitute word substitute null

testing

chicken-install -test

todo if ur bored

  • Escapes
  • Inplace
  • Add reference tests against envsubst
  • Add --posix

About

Simple templating with parameter expansion

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages