turtle icon indicating copy to clipboard operation
turtle copied to clipboard

Support querying environment variable presence/absence

Open Gabriella439 opened this issue 1 year ago • 2 comments

Fixes #452

Gabriella439 avatar Mar 02 '24 05:03 Gabriella439

I'm happy to add an "env" or something to the names to address (1) so I'll do that.

I'm a bit surprised about (2) because I had the opposite point of view (that isPresent / isAbsent were the footguns). The reason why is that treating an in-band value (the empty value) as a sentinel value that means unset is a common source of programming errors (not just in Bash, but in general). Like, in the case of a simple binary toggle this is less of a concern, but when the environment value stores an actual payload that the program will use then there is a greater risk that the payload can be meaningfully present, but empty.

Gabriella439 avatar Mar 04 '24 20:03 Gabriella439

Hmm, that's true. In my experience most environment variables are used for simple toggles. I would also expect the program to do some validation if the environment variable has semantics (e.g. check that a path exists if it's supposed to represent a path, etc.).

9999years avatar Mar 04 '24 20:03 9999years