dotenv-for-MATLAB
dotenv-for-MATLAB copied to clipboard
White space between variable name and equal sign "=" not supported
trafficstars
If the .env file has a field written as
MY_VAR_NAME = my_value
the parsing to a struct will fail because the struct fields cannot contain whitespaces
Recommend adding a test case here: https://github.com/mathworks/dotenv-for-MATLAB/blob/f9ba545f0468148409f7cdb7b59d24a148fc43e0/config/whitespace.env#L3
MY_VAR = my_value
Possible Solution: Change
https://github.com/mathworks/dotenv-for-MATLAB/blob/f9ba545f0468148409f7cdb7b59d24a148fc43e0/dotenv.m#L56
to
expr = "(?<key>.+?)\s*=\s*(?<value>.*)";
could also use STRTRIM on the resulting key/value string results instead
@gwolffblues thanks for finding this. I don't work for MathWorks any longer so I can't fix it. I'll ping someone there to see if they could submit a fix.