bug-bash
[Top][All Lists]
Advanced

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

Re: Sub-arrays do not work with non-blank IFS


From: Jan Schampera
Subject: Re: Sub-arrays do not work with non-blank IFS
Date: Tue, 29 Jan 2008 20:28:06 +0100
User-agent: IceDove 1.5.0.14pre (X11/20071018)

Lea Wiemann wrote:
> 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
> uname output: Linux fly 2.6.22-3-686 #1 SMP Mon Nov 12 08:32:57 UTC 2007
> i686 GNU/Linux
> Machine Type: i486-pc-linux-gnu
> 
> Bash Version: 3.1
> Patch Level: 17
> Release Status: release
> 
> Description:
> 
> If the IFS does not contain a blank, copying an array using
> ("${array[@]}") works, but creating a sub-array using
> ("${array[@]:offset:length}") does not work.
> 
> Repeat-By:
> 
> IFS=$'\n'
> a=(A B C D)
> b=("${a[@]}")
> echo "${#b[@]}", "${b[@]}"  # 4, A B C D -- OK
> b=("${a[@]:2}")
> echo "${#b[@]}", "${b[@]}"  # 1, C D -- bug, should be 2, C D

I assume:

"${array[@]}" is defined (see manual) to expand as separate words.
"${array[@]:x:y}" will "just expand"

>From my understanding this is the correct behaviour.

J.





reply via email to

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