dotenv-hs icon indicating copy to clipboard operation
dotenv-hs copied to clipboard

dotenv picks the first instead of the last value

Open rudymatela opened this issue 5 years ago • 1 comments

See:

$ cat > my_script.hs
#!/bin/bash
echo $FOO
echo $GOO
^D
$ cat > .env
#!/bin/sh
FOO=first
GOO=second
FOO=third
^D
$ dotenv -f.env ./my_script.hs 
first
second

I would expect for the result to be actually:

third
second

Now, that may be just a personal preference... However I justify it as it is less surprising for dotenv files to behave like shell scripts and have a preference for the last set value:

$ source .env
$ echo $FOO
third
$ echo $GOO
second

rudymatela avatar Apr 29 '20 15:04 rudymatela

I was wondering if Python's dotenv behaved in the same way. Looks like Python's dotenv is different from Haskell's but equal to bashes source:

$ pip install python-dotenv
...
$ file .local/bin/dotenv 
.local/bin/dotenv: Python script, ASCII text executable
$ .local/bin/dotenv -f.env run ./my_script.hs 
third
second

rudymatela avatar Apr 29 '20 15:04 rudymatela

Hello @rudymatela This issue and your PR (#122) have been open for a very long time. Let's try to wrap it up.

I like the idea to have tools working in a similar way and I would like to see how other dotenv tools behave. I'll ask a member in my team to take a look at this and report their findings.

CristhianMotoche avatar Mar 20 '23 16:03 CristhianMotoche

Hello! @anddriex is going to give a look at this issue to replicate something similar to what other dotenv tools are doing.

CristhianMotoche avatar Apr 03 '23 16:04 CristhianMotoche

Solved by #161 thanks for the contribution @anddriex and thankd @rudymatela for reporting it!

CristhianMotoche avatar Apr 19 '23 18:04 CristhianMotoche