s6: the s6-envdir program
Keywords: s6 command s6-envdir dir environment modification

s6
Software
skarnet.org

# The s6-envdir program

s6-envdir changes its environment, then executes into another program.

## Interface

         s6-envdir [ -I | -i ] [ -n ] [ -f ] [ -L ] [ -c nullis ] dir prog...

- s6-envdir reads files in dir. For every file f in dir, that does not begin with a dot and does not contain the '=' character:
- If f is empty, remove a variable named f from the environment, if any.
- Else add a variable named f to the environment (or replace f if it already exists) with the first line of the contents of file f as value. Spaces and tabs at the end of this line are removed, as well as any trailing newline; null characters in this line are changed to newlines in the environment variable.

## Options

- `-i` : strict. If dir does not exist, exit 111 with an error message. This is the default.
- `-I` : loose. If dir does not exist, exec into prog without modifying the environment first.
- `-f` : verbatim mode. All the file is given as the value of the environment variable, including newlines (except the last one if the `-n` option is not given). Null characters are still translated.
- `-n` : do not chomp. If the `-f` option is given and the file ends with a newline, keep that last newline in the value. If the `-f` option is not given, keep the trailing blanks at the end of the first line (but not the ending newline).
- `-L` : do not clamp. With this option, s6-envdir will process the whole first line of each file (if the `-f` option hasn't been given) or read each file entirely (if the `-f` option has been given), even if it means adding huge variables to the environment. Without this option, s6-envdir only reads the first 4096 bytes of each file.
- `-c` nullis : replace null characters with the first character of nullis instead of a newline.

## Notes

s6-envdir without options behaves exactly like envdir.