-
-
Save aljp/9c16e953d322fdacbb4515d711454cdc to your computer and use it in GitHub Desktop.
Given a .env file in the working directory with lines in the format ENV_NAME=ENV_VALUE, it will assign these environment variables
This file contains 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
MY_ENV=MY_VAL | |
MY_ENV_2=MY_VAL_2 | |
MY_ENV_3=MY_VAL_3 | |
MY_ENV_WITH_EQUAL=MY_VAL=BROKEN |
This file contains 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
SETLOCAL ENABLEEXTENSIONS :: This actually prevents environment variables from being modified and you should remove this line if you mean to use it | |
SET me=%~n0 | |
SET parent=%~dp0 | |
@ECHO OFF | |
:: Currently has an issue where if the value has an = in it (such as our secret key!) then it only gets the value up to the first = | |
FOR /f "tokens=1,2 delims==" %%a IN (.env) DO ( | |
SET "%%a=%%b" | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment