On Wed, Feb 18, 2015 at 9:13 AM, Salvatore Bonaccorso wrote: > Hi, > > On Wed, Feb 11, 2015 at 11:10:24PM +0100, Jiri Horner wrote: >> Problem is caused by name collision in local variables, which are >> apparently not very local in this case (maybe also dash problem?) > > Just an additional comment on this: It looks actually as intended that > the initial value is inherited, the manpage state: > > Variables may be declared to be local to a function by using a > local command. This should appear as the first statement of a > function, and the syntax is > > local [variable | -] ... > > Local is implemented as a builtin command. > > When a variable is made local, it inherits the initial value and > exported and readonly flags from the variable with the same name > in the surrounding scope, if there is one. Otherwise, the > variable is initially unset. The shell uses dynamic scoping, so > that if you make the variable x local to function f, which then > calls func‐ tion g, references to the variable x made inside g > will refer to the variable x declared inside f, not to the global > variable named x.
I think this may be a design flaw in dash; seems bash doesn't suffer the same issue: $ cat testme testme() { x=backfromthedead local x echo $x } testme $ bash testme $ dash testme backfromthedead -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org