Earlier quoted context omitted.
I've used direnv, but I think a nice property of OP's dotenv is that it's explicit: if I want to pass env vars, I run my program under it. If I don't, then I don't. There's no "hidden behavior" for me to forget about and then get surprised by.
As far as I'm aware of, Direnv's behavior is not hidden at all. Whenever you cd into the directory, you get a message listing all the new en var activated. And when you change the .envrc, you get another message saying that direnv has been deactivated. I never had happen to me "oh shoot !! I forgot this env var was activated because I'm in this dir".
Show HN: Dotenv, if it is a Unix utility
21–30 of 108 posts
Re: Show HN: Dotenv, if it is a Unix utility
#22Re: Show HN: Dotenv, if it is a Unix utility
#23Earlier quoted context omitted.
what are the suggestions
GPT-4: The code provided has a few potential issues, including security vulnerabilities: Buffer Overflow and Memory Allocation Errors: The malloc function in read_file does not check if the memory allocation fails (it checks if buffer is NULL instead of buffer). This can lead to a null pointer dereference if malloc fails and returns NULL. There's a possibility of buffer overflow or improper handling if the file size…
* MAX_FILE_SIZE: I don't think this is true.
* skip_until_charset, skip_charset bound check bug: I don't think this is true
* Uninitialized value_end: I don't think this is true - and if true should be caught by -Wall -Werror flags.
* argc * Error Handling: Currently all parsing errors should cause the program to exit, which I think is the desired behavior.
* Unsanitized input for .env: Intended behavior.
* Unsanitized input for execvp: Intended behavior.
Re: Show HN: Dotenv, if it is a Unix utility
#24There is also shdotenv that allows you to load different .env file formats and convert between them, e.g. for UNIX shell. https://github.com/ko1nksm/shdotenv
Re: Show HN: Dotenv, if it is a Unix utility
#25Earlier quoted context omitted.
GPT-4: The code provided has a few potential issues, including security vulnerabilities: Buffer Overflow and Memory Allocation Errors: The malloc function in read_file does not check if the memory allocation fails (it checks if buffer is NULL instead of buffer). This can lead to a null pointer dereference if malloc fails and returns NULL. There's a possibility of buffer overflow or improper handling if the file size…
I think if you're not willing to manually verify the output of these generative machine learned algorithms, then you probably shouldn't present them to somebody as if you've done them the service of a free code review.
Re: Show HN: Dotenv, if it is a Unix utility
#26Earlier quoted context omitted.
GPT-4: The code provided has a few potential issues, including security vulnerabilities: Buffer Overflow and Memory Allocation Errors: The malloc function in read_file does not check if the memory allocation fails (it checks if buffer is NULL instead of buffer). This can lead to a null pointer dereference if malloc fails and returns NULL. There's a possibility of buffer overflow or improper handling if the file size…
I think if you're not willing to manually verify the output of these generative machine learned algorithms, then you probably shouldn't present them to somebody as if you've done them the service of a free code review.
I don't it hard to believe that they truly believe they're doing us a favor. Surely they're doing it just to feel smart or included?
Re: Show HN: Dotenv, if it is a Unix utility
#27This idea seems to be cloned everywhere now, so something is causing the popularity
Re: Show HN: Dotenv, if it is a Unix utility
#28Would not sh -c '. .env; echo $MY_VAR' do the same thing? (I am not in front of a shell at the moment.)
I have this on my .bashrc:
alias loadenv='export $(xargs
source: [1]--
Re: Show HN: Dotenv, if it is a Unix utility
#29 export $(cat .env | xargs)
Agree with the premise but this can be achieved with actual Unix concepts no need for anything else.The language runtime dotenv projects are banned in my engineering org.
Re: Show HN: Dotenv, if it is a Unix utility
#30Would not sh -c '. .env; echo $MY_VAR' do the same thing? (I am not in front of a shell at the moment.)
There are like a couple dozen different ways to do this... I have this on my .bashrc: alias loadenv='export $(xargs source: [1] -- 1: https://stackoverflow.com/a/60406814/855105