ENVFILE(1)

NAME
envfile - read a file containing variable assignments, add the variables to the environment, then execute a program

SYNOPSIS
envfile [-i | -I] file prog...

DESCRIPTION
envfile reads file and adds the key-value pairs defined in file to the environment. Then it execs into prog..., i.e. the rest of its command line, with the modified environment.

  File syntax
file is a text file containing lines of the form ‘key = value’. Whitespace is permitted before and after key, and before or after value.

Empty lines, or lines containing only whitespace, are ignored. Lines beginning with ‘#’ (possibly after some whitespace) are ignored (and typically used for comments). Leading and trailing whitespace is stripped from values; but a value can be double-quoted, which allows for inclusion of leading and trailing whitespace.

A non-commented line that ends with a backslash ( “\”) is concatenated with the following one, and the newline character is ignored. If a backslashed newline happens before the start of a value, then the whitespace at the beginning of the new line will be part of the value (i.e. leading whitespace on a new line is not stripped).

C escapes, including hexadecimal and octal sequences, are supported in quoted values. Unicode codepoint sequences are not supported. It is possible to include a newline in a quoted value by using ‘\n’; but including newlines in environment variables is not recommended.

If value is empty, key is still added to the environment, with an empty value. If you do not want key to be added to the environment at all, comment out the line. envfile does not offer a way to remove variables from the environment.

The envfile format is largely compatible with systemd's EnvironmentFile[1] format, which allows for the reuse of such files outside of systemd.

If file is ‘-’ then envfile reads and parses its standard input instead. To read a file literally named ‘-’, you can use ‘./-’ for instance.

The variables that can be defined with envfile are purposefully restricted. If you need more expressive power for your variable names, or for your values, you should use an envdir instead: see s6-envdir(8).

OPTIONS

-i  Strict. If file does not exist, exit 111 with an error message. This is the default.

-I  Loose. If file does not exist, exec(3) into prog without modifying the environment.

EXIT STATUS

1   Syntax error in file.

100 Wrong usage.

111 System call failed.

126 execve(2) on prog failed (unknown reason).

127 execve(2) on prog failed ( prog could not be found.)

0 is not listed because on success, envfile does not exit: it execs into prog.

SEE ALSO
emptyenv(1), exec(1), execline-cd(1), execline-umask(1), exit(1), export(1), fdblock(1), fdclose(1), fdmove(1), fdreserve(1), fdswap(1), getcwd(1), getpid(1), heredoc(1), piperw(1), posix-cd(1), posix-umask(1), redirfd(1), trap(1), tryexec(1), unexport(1), wait(1), withstdinas(1), execve(2), exec(3), s6-envdir(8)

[1] https://www.freedesktop.org/software/systemd/man/systemd.exec.html#EnvironmentFile=

This man page is ported from the authoritative documentation at: https://skarnet.org/software/execline/envfile.html

AUTHORS
Laurent Bercot Alexis <flexibeast@gmail.com> (man page port)