Go to file
2026-02-16 08:40:46 +01:00
.gitignore Initial commit: Go clone of daemontools envdir 2026-02-16 08:40:46 +01:00
go.mod Initial commit: Go clone of daemontools envdir 2026-02-16 08:40:46 +01:00
LICENSE Initial commit: Go clone of daemontools envdir 2026-02-16 08:40:46 +01:00
main.go Initial commit: Go clone of daemontools envdir 2026-02-16 08:40:46 +01:00
README.md Initial commit: Go clone of daemontools envdir 2026-02-16 08:40:46 +01:00

envdir

A Go clone of the daemontools envdir program.

Install

go install sneak.berlin/go/envdir@latest

Usage

envdir dir child [args...]

envdir sets various environment variables as specified by files in dir, then runs child with the given arguments.

If dir contains a file named FOO whose first line is bar, envdir sets the environment variable FOO to bar, then runs child.

Rules

  • Each file in dir corresponds to one environment variable. The filename is the variable name and the first line of the file is the value.
  • If a file is empty, the corresponding variable is unset.
  • NUL bytes (\0) in file contents are replaced with newlines.
  • Trailing spaces and tabs are stripped from the value.
  • Lines after the first newline are ignored.
  • Subdirectories and files with = in the name are skipped.
  • Exit code is 111 if envdir encounters an error.

Example

$ mkdir /tmp/env
$ echo -n "production" > /tmp/env/APP_ENV
$ echo -n "localhost:5432" > /tmp/env/DB_HOST
$ envdir /tmp/env printenv APP_ENV
production

License

MIT