Skip to main content

Module dotenv

Module dotenv 

Source
Expand description

The dotenv files that env.load_file and env.read read.

A dotenv file holds one assignment per line, NAME=value, optionally after export and whitespace. Blank lines and lines whose first non-blank character is # are skipped. A value is either unquoted, the rest of the line with surrounding whitespace removed, or quoted:

  • single quotes keep every character literally, up to the closing quote;
  • double quotes support the escapes \n, \t, \" and \\, and no other.

After a closing quote only whitespace may follow. A name starts with a letter or _ and continues with letters, digits, and _. There is no ${VAR} expansion: $ is an ordinary character. When a name is assigned twice, the later value wins. Any other line is a syntax error that names its line, and it fails the task.

Structs§

DotenvError
A line of a dotenv file that is not blank, not a comment, and not an assignment in a supported form.

Functions§

parse
Parse the dotenv text into its variables.