Re: .env file handling

From: Colin Booth <>
Date: Tue, 24 Oct 2017 06:28:27 +0000

On Tue, Oct 24, 2017 at 06:22:46AM +0000, Laurent Bercot wrote:
> > I tried rewriting the whole thing in execline and while I'm pretty sure
> > it's doable it's not easy.
> A direct translation of Casper's script to execline could be:
> #!/command/execlineb -P
> backtick LIST { cat /path/to/xyz.env }
> importas -nsd"\n" LIST LIST
> env -i ${LIST}
> /path/to/xyz
> It's not as idiomatic as other ways to handle variables in execline,
> but it should work.
I regularly forget that env does its work by chainloading as opposed to
being a built-in that manipulates the shells environment directly.
> The underlying difficulty with Monty's question is that execline tries
> to avoid parsing as much as possible, and a file full of key=value lines,
> as simple as it is, still requires some parsing. execline wasn't made
> for this; the idiomatic way to store key-value pairs in the filesystem
> for use by an execline script is, as Monty found out, s6-envdir.
> If you really want a shell-like syntax, the best way to handle it is
> with tools that already understand this syntax, such as a shell, or as
> Casper suggested, env.
I would say that is one of the two difficulties. The other one being
that execline also tries hard not to carry any overhead, which means
that often times you can end up in situations where the aggressive
scoping that it does makes things challenging at best (assuming you're
trying to stay with the spirit of the language).

Colin Booth
Received on Tue Oct 24 2017 - 06:28:27 UTC

This archive was generated by hypermail 2.3.0 : Sun May 09 2021 - 19:38:49 UTC