Re: s6-envdir scope

From: Laurent Bercot <>
Date: Sat, 23 Aug 2014 00:59:13 +0100

On 22/08/2014 23:32, John Vogel wrote:
> I'm hoping this is right and also all by design

  You are correct, and it is by design indeed, but not my design -
it's simply Unix.

  As a very rough rule of thumb, execline blocks represent processes.
A sequence of commands in the same block will run with the same PID;
the environment set with s6-envdir will then propagate to the end
of the block. A new process will be spawned to run an inner block,
and it will inherit that environment. And when a block ends, the
process dies, and the outer block, an ancestor, has no idea of the
environment that was set in the inner block.

  There are many exceptions to the "block = process" rule, but if
you're only concerned with environment scoping, it always behaves
according to that rule. When you set an environment variable, its
scope is always from the point where you set it to the end of the
current block, including all the inner blocks.

  There is *one* exception: "ifthenelse -s". Here, environment will
leak out of the then-block or the else-block into the remainder part.
But it's such an ugly hack, so out of place with the rest of the
execline design, that I'm not even sure I should keep that option
available in 2.0.

Received on Fri Aug 22 2014 - 23:59:13 UTC

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