[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Referencing empty array with "set -u" active throws error
From: |
jens . schmidt35 |
Subject: |
Referencing empty array with "set -u" active throws error |
Date: |
Fri, 17 Dec 2010 10:48:04 +0100 (CET) |
Configuration Information [Automatically generated, do not change]:
Machine: sparc
OS: solaris2.9
Compiler: /sapmnt/global/tools/compiler/SS11/SUNWspro/bin/cc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='sparc'
-DCONF_OSTYPE='solaris2.9' -DCONF_MACHTYPE='sparc-sun-solaris2.9'
-DCONF_VENDOR='sun'
-DLOCALEDIR='/sapmnt/oraicall/home/tools/bash-4.1/share/locale'
-DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -DSOLARIS -I. -I. -I./include
-I./lib -I./lib/intl
-I/net/sapmnt.home2/oraic/tmp/bash_sunos_sun4u/bash-4.1/lib/intl -g
uname output: SunOS us0111 5.9 Generic_117171-12 sun4u sparc SUNW,Sun-Fire-V440
Machine Type: sparc-sun-solaris2.9
Bash Version: 4.1
Patch Level: 0
Release Status: release
Description:
Referencing empty array with "set -u" active throws unbound variable error.
Repeat-By:
$ set -u
$ declare -a array
$ array=( )
$ echo "${array[@]}"
bash: array[@]: unbound variable
For an empty "$@" this does not throw an "unbound" error, which seems to be
an inconsistent behaviour to me.
Workaround:
Use the infamous empty array work-around:
$ echo ${argv[0]+"${argv[@]}"}
- Referencing empty array with "set -u" active throws error,
jens . schmidt35 <=