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
 > 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
 > dotenv parsers, not a requirement.


You're asking for a specialized parser, then.

 > So the goal is not to write a parser, but more of a translator that
 > .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.



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:


Message sent via Savannah

Reply via email to