• Laser@feddit.org
    link
    fedilink
    arrow-up
    1
    ·
    4 hours ago

    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.

    • Caveman@lemmy.world
      link
      fedilink
      arrow-up
      1
      ·
      3 hours ago

      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.