Cipherd@lemmy.ml to Programmer Humor@programming.dev · 9 天前functionslemmy.mlimagemessage-square119linkfedilinkarrow-up1658arrow-down19file-textcross-posted to: [email protected]
arrow-up1649arrow-down1imagefunctionslemmy.mlCipherd@lemmy.ml to Programmer Humor@programming.dev · 9 天前message-square119linkfedilinkfile-textcross-posted to: [email protected]
minus-squareCaveman@lemmy.worldlinkfedilinkarrow-up1·8 天前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.
minus-squareLaser@feddit.orglinkfedilinkarrow-up1·8 天前That doesn’t help you if you want to get the result of something that happened in the function without capturing stdout, does it?
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.
That doesn’t help you if you want to get the result of something that happened in the function without capturing stdout, does it?