Giter VIP home page Giter VIP logo

expenv's Introduction

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.

expenv's People

Contributors

blang avatar jeanmertz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.