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

Programmer Humor

27673 readers
511 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
[–] SlurpingPus@lemmy.world 4 points 1 week ago* (last edited 1 week ago) (2 children)

Functions are definitely not subshells in Bash, seeing as anything modifying the environment, like pyenv and such, is implemented as functions instead of scripts — specifically because functions are run in the same shell instance.

Unless 'subshell' means something in the vein of 'like a new shell, but not really'.

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

Functions are definitely not subshells in Bash

You're right, my bad, I got this mixed up with something else.

[–] Lifter@discuss.tchncs.de 1 points 1 week ago (1 children)

Try doing cd inside a function and then pwd in the main script. Does it move the main script too?

[–] SlurpingPus@lemmy.world 1 points 1 week ago* (last edited 1 week ago)

I'm gonna bet yes for the simple reason that various helper scripts exist that do advanced cd history, with fuzzy search and whatnot, and they can't be implemented as anything other than functions.