bug-bash
[Top][All Lists]
Advanced

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

declare -a list=('*') expands quoted '*' during assignment.


From: david . b . james
Subject: declare -a list=('*') expands quoted '*' during assignment.
Date: Fri, 20 Feb 2004 13:29:59 +0000 (GMT)

Configuration Information [Automatically generated, do not change]:
Machine: sparc
OS: solaris2.8
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='sparc' 
-DCONF_OSTYPE='solaris2.8' -DCONF_MACHTYPE='sparc-sun-solaris2.8' 
-DCONF_VENDOR='sun' -DSHELL -DHAVE_CONFIG_H  -I.  -I. -I./include -I./lib 
-I/app/util/include -O2 -g -pipe
uname output: SunOS ln-dist 5.8 Generic_108528-15 sun4u sparc SUNW,Ultra-80
Machine Type: sparc-sun-solaris2.8

Bash Version: 2.05b
Patch Level: 0
Release Status: release

Description:

  Declaring and assigning an array variable using 'declare -a
  name=(...)' expands quoted filename patterns in the array elements
  during the assignment.

  This is unexpected and different from the behaviour of array
  assignment using plain 'list=(...)'. Following execution of the two
  statements below, list1 and list2 would have different contents.

    list1=(one two three '*')

    declare -a list2=(one two three '*')

Repeat-By:

  The following short script shows the behaviour:

    ---- cut here ----
    #!/.../bash

    tmpdir=/tmp/bash-$$

    rm -rf $tmpdir
    mkdir -p $tmpdir
    cd $tmpdir

    touch four five six

    list1=(one two three '*')
    declare -p list1

    declare -a list2=(one two three '*')
    declare -p list2
    ---- cut here ----

  When run using bash -x, the following output is produced:

    + tmpdir=/tmp/bash-2060
    + rm -rf /tmp/bash-2060
    + mkdir -p /tmp/bash-2060
    + cd /tmp/bash-2060
    + touch four five six
    + list1=(one two three '*')
    + declare -p list1
    declare -a list1='([0]="one" [1]="two" [2]="three" [3]="*")'
    + declare -a 'list2=(one two three *)'
    + declare -p list2
    declare -a list2='([0]="one" [1]="two" [2]="three" [3]="five" [4]="four" 
[5]="six")'
   

Fix:

  Not known to me.




reply via email to

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