envdir — set environment variables then chain
envdir [--ignore-nodir] [--full] [--chomp] {dir} {next-prog}
envdir is a chain-loading utility that sets and unsets environment variables
according to the files in dir
and then chain loads to next-prog with the
execvp(3) function.
next-prog may contain its own command line options, which envdir will ignore.
Unless the [--ignore-nodir] command line option is used,
the non-existence of dir, or it being something
other than a directory, is a fatal error.
For each file file in dir:
If the file is empty, envdir unsets the variable
file if it is set.
Otherwise envdir sets the variable
file, overwriting its existing value if it has one, to the
contents of file, after turning NUL characters into LF
characters.
If the [--full] command line option is used,
envdir uses the full contents of file;
otherwise it uses just the first line of those contents.
If the [--chomp] command line option is used, each line used has leading and trailing whitespace characters trimmed.
envdir skips directory entries that aren't regular files (or symbolic links to regular files), trying not to even attempt to open them if the operating system's directory scanning ability includes the reporting of entry types. It also skips entries whose names begin with a dot.
envdir makes no attempt to sanitize the contents of file or the name
file.
If the name or the contents contain an = character, counter-intuitive things
will happen to the environment.
If the contents have whitespace at the end of the first line, that will be
included in the variable's value in the environment.