NAME
envdot - Read .env file and turn its content into environment variables for different shells.
VERSION
version 0.017_001
SYNOPSIS
envdot [options]
eval `envdot`
Options: --help --man --version --export --no-export --shell -s --dotenv -e
CLI interface without dependencies
The envdot command is also available as a self contained executable. You can download it and run it as it is without additional installation of CPAN packages. Of course, you still need Perl, but Perl comes with any normal Linux installation.
This can be convenient if you want to, for instance, include envdot in a docker container build.
curl -LSs -o envdot https://raw.githubusercontent.com/mikkoi/env-dot/main/envdot.self-contained
chmod +x ./envdot
DESCRIPTION
envdot reads your .env file and converts it into environment variable commands suitable for different shells (shell families): sh, csh and fish.
.env files can be written in different flavors. envdot supports the often used sh compatible flavor and the docker flavor which are not compatible with each other.
If you have several .env files, you can read them in at one go with the help of the environment variable ENVDOT_FILEPATHS. Separate the full paths with ':' character.
Env::Dot will load the files in the reverse order, starting from the last. This is the same ordering as used in PATH variable: the first overrules the following ones, that is, when reading from the last path to the first path, if same variable is present in more than one file, the later one replaces the one already read.
If you have set the variable ENVDOT_FILEPATHS, then envdot will use that. Otherwise, it uses the command line parameter. If no parameter, then default value is used. Default is the file .env in the current directory.
NAME
envdot - Read .env file and turn its content into environment variables for different shells.
OPTIONS
- --help
-
Print a brief help message and exits.
- --man
-
Prints the manual page and exits.
- --version
-
Prints the version and exits.
- --export, --no-export
-
Write commands to set variables for local shell or for exporting them. You usually want to export the variables to all subsequent programs and subshells, i.e. make them into environment variables.
Default: export
- -s, --shell
-
Which shell (family) are you using? Supported: sh, csh, fish.
Default: sh
- -e, --dotenv
-
Path to .env file.
Default: current directory .env
EXAMPLES
eval `envdot --no-export --shell csh`
eval `envdot --dotenv subdir/.env`
ENVDOT_FILEPATHS='../.env:subdir/.env:.env' eval `envdot`
DEPENDENCIES
No external dependencies outside Perl's standard distribution.
SEE ALSO
Env::Assert will verify that you certainly have those environmental variables you need. It also has an executable which can, for example, be used to perform the check in the beginning of a docker container run.
Dotenv is another package which implements functionality to use .env files in Perl.
shdotenv is a project to provide dotenv for shells with support for POSIX-compliant and multiple .env file syntax.
AUTHOR
Mikko Koivunalho <mikkoi@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2023 by Mikko Koivunalho.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.