[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug #62595] Add ability to read .env files into make and
From: |
anonymous |
Subject: |
[bug #62595] Add ability to read .env files into make and |
Date: |
Fri, 10 Jun 2022 10:03:13 -0400 (EDT) |
Follow-up Comment #6, bug #62595 (project make):
> â External Email
>
> 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.
<snip>
You're asking for a specialized parser, then.
> So the goal is not to write a parser, but more of a translator that
converts
> .env syntax to make syntax.
>
The write a translator of arbitrary shell syntax, you need a parser.
Rather than update Make for this special case, I think it would be
better to write a small shell wrapper for Make that reads each line of
the 'env' file, and either writes a post-processed file that Make can
read, or just export the variables into the current shell before
invoking make.
Here's a simple example to show you the concept.
#!/bin/bash
FILE=$(pwd)/example.env;
while read LINE ; do
IFS='=' read -r key value <<<${LINE};
eval ${LINE};
echo "input : ${LINE}";
echo "key/value : '${key}' / '${value}'";
echo "evaluated : ${!key}";
echo "Make output: ${key}=${!key}";
echo "";
done <${FILE};
Escaping special characters (like '#') before exporting to make is not
implemented, but should be trivial to do before evaluating 'LINE' into
the environment.
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?62595>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [bug #62595] Add ability to read .env files into make and, Chigozirim Chukwu, 2022/06/08
- [bug #62595] Add ability to read .env files into make and, Paul D. Smith, 2022/06/08
- [bug #62595] Add ability to read .env files into make and, Chigozirim Chukwu, 2022/06/08
- [bug #62595] Add ability to read .env files into make and, Paul D. Smith, 2022/06/09
- [bug #62595] Add ability to read .env files into make and, Chigozirim Chukwu, 2022/06/10
- [bug #62595] Add ability to read .env files into make and, Martin Dorey, 2022/06/10
- [bug #62595] Add ability to read .env files into make and,
anonymous <=
- [bug #62595] Add ability to read .env files into make and, Paul D. Smith, 2022/06/11
- [bug #62595] Add ability to read .env files into make and, Chigozirim Chukwu, 2022/06/13