On Wed, 6 Jul 2022 at 08:34, Yair Lenga <yair.le...@gmail.com> wrote:
> in general, for complex scripts, I prefer to move the ‘main’ logic into a > function (‘main’, ‘run’,…). This make it possible to keep clean name space. > Otherwise, all the main variables are becoming global: see below for ‘x’. > With many variables, it can be ugly. > > Function main () { > Local x. # x is local > For x in a b ; do process $x ; done > } > > Vs. > # x is global, all function will see it. > For x in a b ; do process $x ; done > Unfortunately that's not how "local" works. In both cases the variable "x" is visible to (and modifiable by) everything that is called from "main"; so everything is inside the "main" function, "local" there is quite indistinguishable from true global. -Martin