Kind of off topic, but why in the world in 2026 do POSIX utilities still rely on global variables to pass around state? Is it too complicated to pass around a struct address in C or something?
Because there's nothing inherently wrong with global variables. In small utilities like these, I would argue it would be less readable to do as you describe.
Sure, in anything larger, or anything that needs to be reentrant, global variables are going to hurt. But this is not that.
dataflow · · focus · HN ↗
kelnos · · focus · HN ↗
Sure, in anything larger, or anything that needs to be reentrant, global variables are going to hurt. But this is not that.