Skip to content

feat(builtins): add dotenv command (non-standard, .env file loader) #572

@chaliy

Description

@chaliy

Summary

A non-standard builtin to load .env files into the shell environment. Every modern project has a .env file. Currently requires export $(cat .env | xargs) which breaks on quotes, comments, and multiline values.

Proposed Syntax

dotenv [OPTIONS] [file...]

Proposed Flags

Flag Description
(default) Load .env in current directory
-f FILE Load specific file
-e / --export Also export variables (default: shell-local)
-o / --override Override existing variables (default: skip existing)
-p / --print Print loaded variables without setting them
--prefix PREFIX Add prefix to all variable names

.env Format Support

# Comments
KEY=value
KEY="quoted value"
KEY='single quoted'
KEY="multi\nline"
EMPTY=
# No value (set to empty)
BARE_KEY

# Variable interpolation
BASE=/app
DATA=${BASE}/data

Use Cases

# Load defaults
dotenv

# Load specific env
dotenv -f .env.production --export

# Load without overriding existing
dotenv -f .env.defaults

# Preview what would be loaded
dotenv -p -f .env.staging

# Load with prefix (for namespacing)
dotenv --prefix DB_ -f database.env
# DB_HOST, DB_PORT, etc.

llm_hint()

Some("dotenv: Load .env files. `dotenv` loads .env, `dotenv -f .env.prod -e` loads and exports. Handles quotes, comments, interpolation.")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions