theskumar / theskumar/python-dotenv
Unable to escape posix expansion
Aperta
@theskumar ci sta già lavorando.
Dal 8/4/2025.
- Lingua principale
- Python
- Stelle
- 8.9k
- Fork
- 581
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
What
Unable to elegantly escape the $ in ${VARIABLE} expansion.
Scenario
.env
VAR=${VARIABLE}
script.py
import os
import dotenv
if dotenv.find_dotenv():
dotenv.load_dotenv(interpolate=False)
print(f"VAR={os.getenv('VAR')}"
I do not see the interpolate kwarg in the documentation, however looking at the stub: https://github.com/theskumar/python-dotenv/blob/914c68ef0e4c2c085d2753f5cbbf304852f37850/src/dotenv/main.py#L307-L330
*Edit: and the pypi documentation:

Expected Behavior
output
>> VAR='${VARIABLE}'
Actual Behavior
output
>> VAR=''
Workaround
My current workaround is to provide the desired string as a default value for variable expansion.
.env
VAR=${_:-${VARIABLE}]
output
>> VAR='${VARIABLE}'
System
Host: Windows 11
Python: 3.10 w/ Poetry environment
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Valutazione
Questa issue non è ancora stata valutata.