[Top][All Lists]

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

Re: typeset -p on an empty integer variable is an error. (plus -v test w

From: Chet Ramey
Subject: Re: typeset -p on an empty integer variable is an error. (plus -v test w/ array elements)
Date: Fri, 11 Jan 2013 17:01:28 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:17.0) Gecko/20130107 Thunderbird/17.0.2

Hash: SHA1

On 1/11/13 1:27 PM, Dan Douglas wrote:
> Bash treats the variable as essentially undefined until given at least an 
> empty value.

This is what Posix says:

        A variable is a parameter denoted by a name.

        A parameter is set if it has an assigned value (null is a valid
        value). Once a variable is set, it can only be unset by using the
        unset special built-in command.

A variable is unset until it has been assigned a value.  Setting attributes
for a variable can change how it behaves when a value is assigned, but does
not assign a value itself, and the variable remains unset -- a simple
placeholder -- until it gets one.  I know there are some inconsistencies in
how bash treats these `invisible' variables, but the above is the way
things are supposed to be.

- -- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/
Version: GnuPG v1.4.11 (Darwin)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/


reply via email to

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