Do people really think env vars are global?
If so, is this because they have a different understanding of how env vars work, or a different understanding of what "global" means?

@wolf480pl "global variables" usually refers to global within the scope of a process. I don't think env vars can be less global than global variables are within a process.

well, if you're talking about doing things inside a process, yeah.

But when thinking about multiple processes or the whole system, I'd expect people to pick up the analogy that process is the new function and system is the new process...

that being said, most programming languages don't have MonadReader-like constructs, so you can't easily do stuff like

with modifiedEnv(foo=42) {
// inside this bloc, nonlocal variable foo is equal 42

@wolf480pl @robby Most people think of environemnt vars in interactive context, and all my interactive shells inherit the same profile, so all processes from my shells inherit those variables from my profile.... so they are global.


@wolf480pl @robby global in the sense that they are always available from all my processes. Not in the technically accurate sense.

· · Web · 1 · 1 · 0

@mbernabe @robby
oh, so people don't write scripts like work-on-project-foo, with-java11, etc. which set a few variables and spawn a project-specific subshell?

@wolf480pl @mbernabe I haven’t really done that before tbh. On Fedora I use the alternatives command for picking java versions, but that needlessly requires root. Otherwise I usually have a .env file for my project that gets sourced when I start my application.

@wolf480pl @robby
I do use that trick myself sometimes, but more for controlling CWD and auto reverting it than anything else. In my experience most people treat shell as batch scripts with very little design or consideration. Which leads to not knowing much shell and using everything as global.

Sign in to participate in the conversation
Mastodon @ SDF

"I appreciate SDF but it's a general-purpose server and the name doesn't make it obvious that it's about art." - Eugen Rochko