Am 12.12.2009 11:24, schrieb Bernd Eggink:
Am 12.12.2009 02:11, schrieb Matthew Woehlke:
konsolebox wrote:
I hope the development team will also consider adding a way in bash to
declare global variables inside a function perhaps either with an
option in typeset or declare like -g (same as zsh) and/or a builtin
function like global as similar to local.
I thought variables in functions were /always/ global unless declared
local?
It's the other way round. Regarding typeset and declare, the man page
says: " When used in a function, makes each name local, as with the
local command. " So within a function, typeset, declare, and local are
synonyms.
To avoid misunderstandings, let me add that you are right (only) with
respect to variables being used _without_ declaration. The problem is
that associative arrays are the only kind of variables that _must_ be
declared, since something like "a[foo]=bar" without a preceding
declaration would create an indexed array (and set a[0] to "bar").
Bernd
--
Bernd Eggink
http://sudrala.de