Gentoo Archives: gentoo-dev

From: Roy Marples <uberlord@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] Opinions Wanted - Arrays again :)
Date: Thu, 25 Oct 2007 21:54:06
Message-Id: 1193348959.2910.9.camel@uberpc.marples.name
In Reply to: Re: [gentoo-dev] Opinions Wanted - Arrays again :) by Donnie Berkholz
1 On Thu, 2007-10-25 at 14:31 -0700, Donnie Berkholz wrote:
2 > Is there any way we could avoid these altogether, and instead use
3 > separate variables for each array element?
4
5 Well, we could prefix with numbers
6
7 array="1.2.3.4 netmask 5.6.7.8;
8 \*
9 'host.name' netmask 1.2.3.4
10 -I 'option; $FOO with spaces'"
11
12 Would become
13
14 0_config_eth0="1.2.3.4 netmask 5.6.7.8;"
15 1_config_eth0="\*"
16 2_config_eth0="'host.name' netmask 1.2.3.4"
17 3_config_eth0="-I 'option; $FOO with spaces'"
18
19 Can't suffix as we use $IFACE and $SSID and sometimes hardware addresses
20 there. We don't have to have 0_, but we would need the other numbers.
21 Advantage - no messy holding an array in a string
22 Disadvantage - you have a big array and need to punt something in the
23 middle :) OK, you could put a "value" in there but each array loop would
24 have to know about this magical value.
25
26 Thanks
27
28 Roy
29
30 --
31 gentoo-dev@g.o mailing list

Replies

Subject Author
Re: [gentoo-dev] Opinions Wanted - Arrays again :) Donnie Berkholz <dberkholz@g.o>