this post was submitted on 22 Nov 2025
651 points (98.7% liked)

Programmer Humor

27673 readers
489 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 

cross-posted from: https://lemmy.ml/post/39334581

you are viewing a single comment's thread
view the rest of the comments
[–] Laser@feddit.org 1 points 1 week ago (1 children)

I didn't mean that bash has no local variables, but rather that if you want to use a function as such without capturing stdout, you need variables that are scoped across your functions, which is usually global or at least effectively global.

[–] olafurp@lemmy.world 1 points 1 week ago (1 children)

Turns out you can, by using () instead of {} in the function declaration you can run the function in a subshell where changes to variables are scoped to the subshell and functions are local.

[–] Laser@feddit.org 1 points 1 week ago

That doesn't help you if you want to get the result of something that happened in the function without capturing stdout, does it?