bug-bash
[Top][All Lists]
Advanced

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

Bash Bug - Word Splitting Rules not obeyed with Redirected Parameter Exp


From: Peter Murray Stockdill (E-mail 2)
Subject: Bash Bug - Word Splitting Rules not obeyed with Redirected Parameter Expansion
Date: Tue, 17 Jun 2003 03:10:24 +1000

I am using Bash 2.05b.0(8)-release as supplied with Cygwin 1.3.20.  I
believe that the following script demonstrates that the Bash word splitting
rules are not obeyed when redirected parameter substitution is used:

------------------------------------------------------------------------
#!/bin/bash

arrayA=("A" "B" "C")

arrayB=(  ${arrayA[*]}  )
echo "Case01---${#arrayB[*]}---${arrayB[0]}:${arrayB[1]}:${array[2]}---"

arrayB=( "${arrayA[*]}" )
echo "Case02---${#arrayB[*]}---${arrayB[0]}:${arrayB[1]}:${array[2]}---"

arrayB=(  ${arrayA[@]}  )
echo "Case03---${#arrayB[*]}---${arrayB[0]}:${arrayB[1]}:${array[2]}---"

arrayB=( "${arrayA[@]}" )
echo "Case04---${#arrayB[*]}---${arrayB[0]}:${arrayB[1]}:${array[2]}---"

xx="arrayA[*]"

arrayB=(  ${!xx}  )
echo "Case05---${#arrayB[*]}---${arrayB[0]}:${arrayB[1]}:${array[2]}---"

arrayB=( "${!xx}" )
echo "Case06---${#arrayB[*]}---${arrayB[0]}:${arrayB[1]}:${array[2]}---"

xx="arrayA[@]"

arrayB=(  ${!xx}  )
echo "Case07---${#arrayB[*]}---${arrayB[0]}:${arrayB[1]}:${array[2]}---"

arrayB=( "${!xx}" )
echo "Case08---${#arrayB[*]}---${arrayB[0]}:${arrayB[1]}:${array[2]}---"

echo "Why are the results for Case08 different than those for Case04?"
-------------------------------------------------------------------------

Have I misunderstood the rules regarding the difference between * and @ when
parameter expansion occurs within double quotes?

Peter Stockdill.





reply via email to

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