Bug 71388 - Array initialisation using $@ works as $*
Summary: Array initialisation using $@ works as $*
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: bash
Version: 7.3
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Tim Waugh
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2002-08-12 22:16 UTC by James Antill
Modified: 2008-05-01 15:38 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2002-09-26 01:56:08 UTC
Embargoed:


Attachments (Terms of Use)

Description James Antill 2002-08-12 22:16:50 UTC
Description of Problem:
 When you initialise an array using ARRAY=($@) the variables get expanded as if
you had used $*.

Version-Release number of selected component (if applicable):
 bash-2.05a-13

How Reproducible:
 Always

Steps to Reproduce:
1. Run attached script

Actual Results:
 Script prints.
2
3
3
3
3

Expected Results:
 Script prints.
2
2
3
2
3


Additional Information:
 Here is the script...

#! /bin/bash

function f()
{
 A=($@)
 B=($*)

 echo $#
 echo ${#A[@]}
 echo ${#B[@]}
 echo ${#A[*]}
 echo ${#B[*]}
}

f a "b c"

Comment 1 Tim Waugh 2002-10-11 11:13:45 UTC
You forgot to quote $@.


Note You need to log in before you can comment on or make changes to this bug.