I learned today that Bash does not support lexical scoping like I'd thought. This means that a function automatically inherits the scope of whatever calls it. I've been operating under the assumption that functions were pure, and *only* had access to arguments that are passed to it.
I am shook. I've been trying to write "functional" Bash, and this basically makes that impossible.
@hisaac what's your take on this?
https://j3s.sh/thought/write-posix-shell.html
Basically "shell is great, but if you love shell, stick to the POSIX spec and a lot of problems that make shell scripting not great will go away"
But also "only use shell for things that its good at. For everything else, there's python3 and its stdlib (or whatever else floats your boat)"
@forestjohnson I think the points are valid! I’ve mostly used Bash for my scripting — haven’t tried to do pure posix — but what they say here makes sense to me.
We’ve got a whole mess of scripts where I work (that I built), so right now I’m trying to find ways to tame the chaos until we convert to some other language.