zimbatm/direnv — pull request #89 by gfxmonk (2013-12-27 07:10:10+00:00)
Title: allow `direnv dump` to be run from any process run by .envrc

`direnv dump` now terminates with a null byte (chosen simply because it definitely won't appear in regular base64-encoded dump output). Also, `direnv dump` always writes to FD 3, which is a pipe set up by the process loading the .envrc.

When the parent process reads the dumped environment, it uses only the _first_ dump (up to the first null byte) - any further dumps are ignored. This allows the user to dump a different process' environment, which is useful with tools that work in sub-processes. For example:

# .envrc
0install run \
http://gfxmonk.net/dist/0install/0env.xml \
http://gfxmonk.net/dist/0install/mocktest.xml \
-- direnv dump

This sets up all the required environment variables in a subprocess, then runs `direnv dump` in that process.

This implements the feature I requested in #85.

Apologies for any failure to follow go-isms, this is my second ever patch to go code ;)