NAME

envdot - Read .env file and turn its content into environment variables for different shells.

VERSION

version 0.003

SYNOPSIS

envdot [options]

eval `envdot`

Options: --help --man --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/master/script/envdot.packed
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.

If you have set the variable DOTENV_FILEPATH, then envdot will use that. Otherwise, it respects the command line parameter. If no parameter, then default value is used. Default is the file .env in the current directory.

convert_variables_into_commands( \%vars, $shell )

Convert variables for different shells: sh, csh, fish

Return a string.

convert_variable( $name, $value )

Print one environmental variable definition according to the wanted shell.

Return a string.

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.

--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 perform the check in the beginning of a docker container run.

Dotenv is another package which implements functionality to use .env files in Perl.

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.