Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: typesetting parameters



On Sun, Jun 13, 2004 at 09:58:57PM -0700, Bart Schaefer wrote:
> On Sun, 13 Jun 2004, lists wrote:
> 
> > 	I'm having difficulty understanding why one would define a parameter 
> > with typeset before using it.
> 
> One probably wouldn't, when interactively typing commands, unless one
> wanted to use the special attributes such as padding, alignment, other
> integer bases, or floating-point precision.
> 
> The primary time/place and reason to use typeset is when defining shell
> functions, to create variables that are local to the function scope. When
> you use "local" that's really an alias for typeset.

Not only that, even outside of functions, some expressions such as

    variable+=$value

will not always behave as intended if the variable is not typeset.  If
it is typeset as an array for example, you can depend on it appending
"$value" to the list.  Otherwise it might try to add it as an integer
or append it as a string, depending on it's value.

Regards,
Vincent

-- 
Vincent Stemen
Avoid the VeriSign/Network Solutions domain registration trap!
Read how Network Solutions (NSI) was involved in stealing our domain name.
http://www.InetAddresses.net



Messages sorted by: Reverse Date, Date, Thread, Author