bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: add a way to declare global variables


From: Stephane CHAZELAS
Subject: Re: add a way to declare global variables
Date: Sat, 12 Dec 2009 19:01:32 +0000 (UTC)
User-agent: slrn/pre1.0.0-16 (Linux)

2009-12-12, 12:37(-05), Chet Ramey:
> On 12/12/09 5:24 AM, Bernd Eggink wrote:
>
>> 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. Using 'local' outside a function is an error, so IMHO this
>> command is completely redundant. It _would_ make some sense, however, if
>> its counterpart 'global' existed, as it could help clarify the intended
>> usage of the variable.
>
> It might be considered redundant, but just consider it a more mnemonic
> synonym for declare/typeset.  `local' appeared in an earlier version of
> the Posix standard, though `typeset' never did.
[...]

"local" is also mandated by the LSB spec for sh as well (Linux
standard base). So you can reasonably expect to be able to use
it (though only in "local varname") on any script meant for a
recent Linux sh.

-- 
Stéphane


reply via email to

[Prev in Thread] Current Thread [Next in Thread]