envfilesubst/README.md

48 lines
992 B
Markdown
Raw Normal View History

2022-05-16 00:06:05 +00:00
# envfilesubst
2023-09-12 19:25:29 +00:00
envfilesubst is a variation of gettext's
[envsubst](https://www.gnu.org/software/gettext/manual/html_node/envsubst-Invocation.html),
with a different modus operandi.
2022-05-16 00:06:05 +00:00
2023-09-12 19:25:29 +00:00
Firstly, instead of reading the current environment it reads from file in
traditional "envfile" format.
2022-05-16 00:06:05 +00:00
2023-09-12 19:25:29 +00:00
Secondly, it will read input from stdin replacing all variable references that
can be matched with the envfile. If variables are not explicitly mentioned in
the envfile, the references will be left untouched (instead of replacing them
with an empty string).
## Git
The main git repo is: https://git.netflux.io/rob/envfilesubst
It is also mirrored on GitHub: https://github.com/rfwatson/envfilesubst
2022-05-16 00:06:05 +00:00
## Installation
```
go install git.netflux.io/rob/envfilesubst@latest
```
## Usage
Given an envfile:
```
2023-09-12 19:25:29 +00:00
# myenvfile
2022-05-16 00:06:05 +00:00
FOO=bar
X=1
```
Then:
```
2023-09-12 19:25:29 +00:00
echo "FOO is $FOO and X is ${X}. I don't know $BAZ." | envfilesubst -f myenvfile
2022-05-16 00:06:05 +00:00
```
The output is:
```
2023-09-12 19:25:29 +00:00
FOO is bar and X is 1. I don't know $BAZ.
2022-05-16 00:06:05 +00:00
```