r/programminghorror • u/sogo00 • Jan 27 '26
Shell How to load a .env into your script
So I asked codex to load the .env into the script to set keys as environment variables and to fix it a few times.
101
Upvotes
31
u/edo-lag Jan 27 '26
Just AI garbage
10
u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo "You live" Jan 27 '26
Damn, I always thought .env was a file extension, not the whole filename.
5
u/Unfair-Rip-5207 Jan 27 '26
Maybe I did too much bash in my life but it's readable.
Could benefit on some comments to explain what each block do, this could help understand the regexes.
5
u/Flimsy_Pumpkin_3812 Jan 28 '26 edited Jan 28 '26
The real horror is the blinding white theme (no offense)
EDIT: nevermind i said nothing I read rule 2
3
u/BoredOfReposts Jan 28 '26
. .env
4
u/knight666 Jan 28 '26
I rewrite bash scripts into Python at every opportunity I get
2
u/Background-Main-7427 Jan 28 '26
Is that a bash script?
1
u/desi_fubu Jan 28 '26
I don't see a problem with it. it's probably for testing framework
1
u/theozero Jan 29 '26
check out https://varlock.dev