bug-bash
[Top][All Lists]
Advanced

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

nounset option and arrays


From: Poor Yorick
Subject: nounset option and arrays
Date: Thu, 05 Feb 2009 14:27:39 -0500
User-agent: Thunderbird 2.0.0.19 (Windows/20081209)

In the following example, I was expecting var2 not to be seen as an unbound variable after it was declared. Wouldn't it be more consistent with the treatment of var1 not to issue the unbound variable error in this case? What is the rationale behind the current behavior?

    bash-3.2$ shopt -s -o nounset
    bash-3.2$ declare var1
    bash-3.2$ echo $var1

    bash-3.2$ declare -a var2
    bash-3.2$ echo $var2
    bash: var2: unbound variable
    bash-3.2$ echo ${var2[@]}
    bash: var2[@]: unbound variable

--
Yorick





reply via email to

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