bug-bash
[Top][All Lists]
Advanced

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

Problem with how to assign an array


From: Steven W. Orr
Subject: Problem with how to assign an array
Date: Thu, 24 Feb 2011 14:55:13 -0500
User-agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101207 Thunderbird/3.1.7

I know how to assign a simple array. My problem is a bit harder.

I have three arrays

a1=(aaa bbb ccc ddd)
a2=(qqq www eee rrr)
a3=(fff ggg hhh)

I then set a_all

a_all=("${a1[*]}" "${a2[*]}" "${a3[*]}"

Later on, I decide which element of a_all I really want. So with my new index calculated, I say

real_a=( ${a_all[index]} )

And it worked really well until today. The problem is that I need an element of the aNs to be allowed to be null values.

Like this:

a1=(aaa bbb ccc ddd '' jjj kkk lll)

such that if index is 0, I'd like real_a to end up with 8 elements instead of 7.

I could create a sentinel, I could use a case statement, I could create all kinds of confabulations, but I'd like to know if there's a better way to do it.

I literally tried everything I could think of.

Thanks :-(

--
Time flies like the wind. Fruit flies like a banana. Stranger things have  .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net



reply via email to

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