3 ms·
The environment variable isn't much better, both are akin to using a global var in your reentrant code, but at least STDDATA_FD is less likely to collide than 3
by veltas 1y ago
The environment variable isn't much better, both are akin to using a global var in your reentrant code, but at least STDDATA_FD is less likely to collide than 3.
Can't wait for scripts using this variable for something unrelated to break when they call my scripts.
This should be a parameter or argv[0]-based.
- bcrl 1y agoThat doesn't work reliably either. No existing code scrubs STDDATA_FD from their environment variables, and there's no way to know if anyone uses STDDATA_FD in the wild. Why not just use a command line parameter like everyone else? Different isn't better in a situation like this. This is a larger concern I've started to see in a certain class of younger developer where existing conventions are just ignored without an attempt at understanding of why they exist. Things are only going to get worse as naive vibe coders start flinging more AI generated garbage out into the world. I pity the pole folks trying to maintain these systems a couple of decades from now.
- veltas 1y agoThat's what I really meant by saying a parameter, it should be an option/flag that's given explicitly at invocation, or just a different program name.
- kps 1y agoJust go for `--json-output=filename` rather than playing games.
- 8n4vidtmkvmk 1y agoWhy filename? It doesn't need to know how to write files. That's what Greater than is for. Do --output=json
- kps 1y agoIt seemed that the author wants to write JSON in addition to regular output.
- 8n4vidtmkvmk 1y agoOh.. ya ok I guess you need to specify where to direct each output then. Kind of a weird use case. If it's not slow to process, you can usually just call the program twice.
- bcrl 1y ago--json-output=/dev/fd/3