Bug 71388 - Array initialisation using $@ works as $*
Array initialisation using $@ works as $*
Status: CLOSED NOTABUG
Product: Red Hat Linux
Classification: Retired
Component: bash (Show other bugs)
7.3
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Tim Waugh
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2002-08-12 18:16 EDT by James Antill
Modified: 2008-05-01 11:38 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2002-09-25 21:56:08 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description James Antill 2002-08-12 18:16:50 EDT
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 07:13:45 EDT
You forgot to quote $@.

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