bug-bash
[Top][All Lists]
Advanced

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

nounset option does not work with array in arithmentic expressions


From: Joerg Boehmer
Subject: nounset option does not work with array in arithmentic expressions
Date: Thu, 16 Dec 2010 20:49:22 +0100
User-agent: KMail/1.13.2 (Linux/2.6.32-26-generic; KDE/4.4.2; i686; ; )

Configuration Information [Automatically generated, do not change]:
Machine: i486
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i486' -
DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i486-pc-linux-gnu' -
DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -
DHAVE_CONFIG_H   -I.  -I../bash -I../bash/include -I../bash/lib   -g -O2 -Wall
uname output: Linux CL3MMH29 2.6.32-26-generic #48-Ubuntu SMP Wed Nov 24 
09:00:03 UTC 2010 i686 GNU/Linux
Machine Type: i486-pc-linux-gnu

Bash Version: 4.1
Patch Level: 5
Release Status: release

Description:
I want to use the nounset option and I found that the option does not work 
with array-values in
         a arithmethic expression. See the following example:

address@hidden:~$ set -o nounset
address@hidden:~$ declare -ai ar
address@hidden:~$ ar[0]=1
address@hidden:~$ let y=ar[1]
address@hidden:~$ echo $y
0

The value of variable ar[1] is expanded to 0 although it was not set.
The full syntax produces the expected behavior:

address@hidden:~$ let z=${ar[1]}
bash: ar[1] ist nicht gesetzt.
                                                                                
                                               
Repeat-By:                                                                      
                                               
permanent


Fix:
The full syntax produces the expected behavior:

address@hidden:~$ let z=${ar[1]}
bash: ar[1] ist nicht gesetzt.



reply via email to

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