First, we'll use a script that does one simple thing. It reads the config file, validates its format, and outputs its contents without any blank lines or comments. The script is significantly more complex than the little snippet we had before, although we're only adding a few modest features. This is a common pattern which should be carefully considered: adding a couple of small features results in a very large increase in complexity. In this case, the added complexity is justified, but we shouldn't make the decision lightly.
The script is called
env-echo.sh and here is what it contains:
#!/usr/bin/env bash # Echoes environment variables from a file # -- ignores comment lines # -- ignores blank lines # -- validates ...