Last active
November 17, 2022 20:49
-
-
Save GLMeece/41cfa15efb2917dea6f3d4c98f1e1f73 to your computer and use it in GitHub Desktop.
Exporting INI file values as Environmental Variables
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# It is assumed that $HOME is already defined and exported... | |
# Assuming within our home directory, | |
# we have a hidden directory called '.env' | |
envvarsdir="/.env/" | |
# ...and within that directory we had a file named 'secret_vars.ini'... | |
envvarsfile=secret_vars.ini | |
# ...we'd build the path | |
envvarspath=$HOME$envvarsdir$envvarsfile | |
if [ -f "$envvarspath" ] | |
then | |
set -a | |
source $envvarspath | |
set +a | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example key/value pairs in an INI file... | |
FOO=bar | |
MYPASS=12345 | |
MYTOKEN=nZNyM-JksGszq-FzHEoh | |
preceding_spaces_are_ok=if_you_are_ok_with_them | |
# Commented lines are ignored. | |
# space_after_equals_sign = will_not_work | |
# Also, sorry - no section names allowed! | |
# DON'T! -> [my_fancy_section_name] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment