Skip to content

feat: add opt-in $(command) substitution for .env values - #685

Open
kavin0x wants to merge 2 commits into
theskumar:mainfrom
kavin0x:feat/env-command-parsing
Open

kavin0x wants to merge 2 commits into
theskumar:mainfrom
kavin0x:feat/env-command-parsing

Conversation

@kavin0x

@kavin0x kavin0x commented Aug 19, 2026

Copy link
Copy Markdown

Summary

Optional $(command) substitution in .env values, off by default.

GITHUB_TOKEN=$(gh auth token)

Turn it on with execute_commands=True on load_dotenv() / dotenv_values(), or --execute-commands on the CLI (list, get, run).

Runs after ${VAR} interpolation, so stuff like PREFIX=${BASE}-$(echo suffix) works. Failed commands warn and resolve to empty string.

Test plan

  • uv run pytest (feature tests green locally)
  • Real subprocesses: $(whoami), $(echo ...), mixed ${VAR} + $(cmd), $(gh auth token)
  • Default stays literal when execute_commands=False
  • CLI flag covered in tests

Notes

  • Nested ) inside $(...) isn't supported (called out in the README)
  • Only for trusted .env files — commands run with the process's permissions

@theskumar CI's been green for a bit. Happy to tweak naming/docs if anything feels off.

kavin0x and others added 2 commits August 18, 2026 21:19
Enable shell command substitution via execute_commands=True on load_dotenv()
and dotenv_values(), or --execute-commands on the CLI, so trusted .env files
can populate variables from command output like gh auth token.

Co-authored-by: Cursor <cursoragent@cursor.com>
Remove the gh auth token integration test that fails on unauthenticated
runners, skip POSIX shell env expansion on Windows, and use python
--version instead of printenv --version in CLI flag tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
@kavin0x

kavin0x commented Sep 14, 2026

Copy link
Copy Markdown
Author

@theskumar

@kavin0x

kavin0x commented Sep 16, 2026

Copy link
Copy Markdown
Author

hey @theskumar — gentle bump. CI is green on this. if command sub isn't something you want in core, lmk and I can close or reshape.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant