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

you are viewing a single comment's thread
view the rest of the comments
[–] 4 points 9 months 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'.

  • source
  • parent
  • hideshow 4 child comments
  • [–] 1 point 9 months ago (1 child)

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

  • source
  • parent
  • hideshow 2 child comments
  • [–] 1 point 9 months ago* (last edited 9 months 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.

  • source
  • parent