[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Revisiting Error handling (errexit)
From: |
Martin D Kealey |
Subject: |
Re: Revisiting Error handling (errexit) |
Date: |
Wed, 6 Jul 2022 13:23:14 +1000 |
On Wed, 6 Jul 2022 at 08:34, Yair Lenga <yair.lenga@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
- Re: Revisiting Error handling (errexit), (continued)
- Re: Revisiting Error handling (errexit), Lawrence Velázquez, 2022/07/05
- Re: Revisiting Error handling (errexit), Yair Lenga, 2022/07/05
- Re: Revisiting Error handling (errexit), Lawrence Velázquez, 2022/07/05
- Re: Revisiting Error handling (errexit), Yair Lenga, 2022/07/05
- Re: Revisiting Error handling (errexit), Lawrence Velázquez, 2022/07/05
- Re: Revisiting Error handling (errexit), Martin D Kealey, 2022/07/06
- Re: Revisiting Error handling (errexit), Yair Lenga, 2022/07/06
- Re: Revisiting Error handling (errexit), Koichi Murase, 2022/07/06
- Re: Revisiting Error handling (errexit), Yair Lenga, 2022/07/06
- Re: Revisiting Error handling (errexit), Koichi Murase, 2022/07/06
- Re: Revisiting Error handling (errexit),
Martin D Kealey <=
- Re: Revisiting Error handling (errexit), Robert Elz, 2022/07/06