bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug #62595] Add ability to read .env files into make and


From: Chigozirim Chukwu
Subject: [bug #62595] Add ability to read .env files into make and
Date: Fri, 10 Jun 2022 01:46:20 -0400 (EDT)

Follow-up Comment #4, bug #62595 (project make):

No, no, that's not something one should expect from a .env file.

I said that _some_ dotenv parsers take it a step further to do all that fancy
interpolation, but really .env files are just files containing a bunch of
key=value lines, no functions or shell parsing necessary. It's just a
configuration file. Variable interpolation is a nice-to-have feature of most
dotenv parsers, not a requirement.

----

Unfortulately I don't think there is a definite spec I can point to, but I
found this one which explains the format
<https://hexdocs.pm/dotenvy/dotenv-file-format.html>. And another one which
talks about the origin
<https://blog.doppler.com/the-triumph-and-tragedy-of-env-files>

To bring this back on topic, I believe "make" already has the capacity to do
what most dotenv parsers are doing. As you can see from the stackexchange page
<https://unix.stackexchange.com/questions/235223/makefile-include-env-file> I
linked earlier, make can already read some simple .env files when included
using the "include" directive, but for others it just needs to be guided a
little. For example:


TEST_VAR='8X46Yj*aek3GQeiW7#bK!Eg@#6vjV'


should be translated into


export TEST_VAR := 8X46Yj*aek3GQeiW7\#bK!Eg@\#6vjV


And something like:


EMAIL=${USER}@example.org


is to be translated to


export EMAIL := $(USER)@example.org


So the goal is not to write a parser, but more of a translator that converts
.env syntax to make syntax.

This feature can be exposed either via a directive within a Makefile
(includeenv) or a flag (--envfile) to make.


    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?62595>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]