aboutsummaryrefslogtreecommitdiff
path: root/README.md
blob: 6d25661e2d273dbc41c2246c48ed04e03676ff33 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
DEEPENV
=======

Deepenv is a tool to run programs with their environment variables
populated from all detected parent .env files merged together.

## Installing

Deepenv is written in Chicken scheme. In order to install it, you will
need to first install Chicken, and compile deepenv.

On Linux, use your package manager to install Chicken like so:

```
sudo apt install chicken-bin
```

On MacOS, install Chicken with Homebrew:

```
brew install chicken
```

Then compile and install Chicken like so:

```
make
make install
```

### Overrides

The following can be overriden by environment or make variables:

- `CSC` the chicken compiler command. Usually `csc`, sometimes `chicken-csc`.
- `PREFIX` file-system prefix where the executables will be installed. Defaults to `/usr/local`.

## Usage

To use deepenv, simply `cd` to the place where you want to run a
program, and run with:

```
deepenv <program> [arguments]
```

If a `.env` file exists in this folder or any parent folder, they will
be loaded as environment variables when `program` runs.

## Environment merging strategy

All `.env` files encountered from the current working directory, all
the way to the filesystem root are loaded and merged together, with
environment variables defined deeper in the tree shadowing their
parent definitions. The very top level is the existing environment
variables.

For example, given the following file structure:

```
/
/.env
+- /foo
   +- .env
```

Assuming `/.env` defines `FOO=123` and `/foo/.env` defines `FOO=456`,
running `deepenv <program>` in `/foo` will result in `FOO` being set
to `456`.