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: Chris F.A. Johnson
Subject: Re: add a way to declare global variables
Date: Sat, 12 Dec 2009 05:28:38 -0500 (EST)
User-agent: Alpine 2.00 (LMD 1167 2008-08-23)

On Sat, 12 Dec 2009, Bernd Eggink wrote:

> 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. 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.

   Of the three, local is the only command I use. It says exactly what
   it does.


-- 
   Chris F.A. Johnson, webmaster         <http://woodbine-gerrard.com>
   ===================================================================
   Author:
   Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
   Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)




reply via email to

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