Created
May 17, 2025 13:42
-
-
Save unlight/7a3c3ef32efedc940992103de1091526 to your computer and use it in GitHub Desktop.
var_loadenv.cmd
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
@echo off | |
if not "x%~1"=="x/?" goto :main | |
echo ============================================= | |
echo Load variables from env file. | |
echo --------------------------------------------- | |
echo usage: | |
echo var_loadenv [option] env-file | |
echo ex: | |
echo type some.txt -^> KEY=VALUE | |
echo var_loadenv some.txt | |
echo echo %%KEY%% ^-> VALUE | |
echo options: | |
echo\ /?: show this usage. | |
echo args: | |
echo env-file: environment file path | |
echo ============================================= | |
exit /b 1 | |
:main | |
if "x%~1"=="x" exit /b | |
for /f "eol=# tokens=1,* delims==" %%i in ( %~f1 ) do ( | |
if not "x%%i"=="x" ( | |
set "%%i=%%j" | |
echo "%%i=%%j" | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment