expenv

command module
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 1, 2016 License: MIT Imports: 7 Imported by: 0

README

expenv - Expand environment variables Build Status

Expenv replaces ${var} or $var in the input to the values of the current environment variables. Supports stdin/stdout and files.

There is also a newer version available, expenv.sh, written as shell script.

Usage

$ go get github.com/blang/expenv
$ $GOPATH/bin/expenv -f inputfile

If you don't want to build it, you might want to download the ELF x86-64 binary of the latest release (build by travis-ci).

Examples

$ expenv -f inputfile > outputfile
$ expenv < inputfile > outputfile
$ expenv -i -f inputfile // Replace inplace

Example input:

My PWD is $PWD
Whoami: ${USER}
I'm using $TERM
Expand $empty but don't expand $$empty
Don't expand $(echo empty)

As mentioned in the above example, two special cases exist:

  • $$ is converted to $, allowing you to pass in literal-dollar-signs
  • $( is not converted, allowing your input to contain subshell like behaviour

Motivation

I need to make config files more dynamic using environment variables. In a docker environment this is a big issue for me.

Contribution

Feel free to make a pull request. For bigger changes create a issue first to discuss about it.

License

See LICENSE file.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL