News for hackers. Stuff that matters.
Re:Conventions for Command Line Options by arp242 on Saturday August 01, 2020 @08:28PM (#24025211)
There's a few reason I don't like environment variables for this: the first is that a random env variable can influence the operation of a program. Do "export foo=bar" and then maybe 30 minutes later you unexpectedly pass "foo". It's also hard to inspect; the output of "env" tends to be somewhat long, and you don't know which the program will pick up on. Flags are much clearer and more explicit.

There's also the issue that typo'ing "foo" as "fooo" will silently fail. Okay, that's a simple example, but some tools have "PROGRAMNAME_LONGDESCRIPTION". Being in all-caps also makes it hard to spot typos for me. You generally want your env vars to be long, so ensure they're unique.

Re:Conventions for Command Line Options by boring_twenties on Saturday August 01, 2020 @09:06PM (#24025429)
> It's also hard to inspect; the output of "env" tends to be somewhat long, and you don't know which the program will pick up on. Flags are much clearer and more explicit.

I don't think I disagree with your post, but this particular point seems to be trivially solved by prefixing the variable name with the program name?

IOW: `env | grep '^GIT_'` to see what you're passing to `git`.

Re:Conventions for Command Line Options by arp242 on Sunday August 02, 2020 @12:26PM (#24029617)
Yeah, fair enough; that's what I do as well.