Gentoo Archives: gentoo-dev

From: Steve Long <slong@××××××××××××××××××.uk>
To: gentoo-dev@l.g.o
Subject: [gentoo-dev] Re: Re: How to pass list of paths to eclass?
Date: Thu, 13 Dec 2007 16:26:42
Message-Id: fjrl51$vhn$1@ger.gmane.org
In Reply to: Re: [gentoo-dev] Re: How to pass list of paths to eclass? by Peter Volkov
1 Peter Volkov wrote:
2
3 > ? ???, 13/12/2007 ? 10:52 +0000, Steve Long ?????:
4 >> Peter Volkov wrote:
5 >> > Speaking about the
6 >> > latter it is:
7 >> >
8 >> > 1. Modify eclass to use arrays:
9 >> >
10 >> > for conffile in ${FONT_CONF[@]}; do
11 >> > ...
12 >> > done
13 >> >
14 >> > 2. Modify ebuilds to use arrays.
15 >> >
16 >> > -FONT_CONF="path1 path2"
17 >> > +FONT_CONF=( "path1" "path2" )
18 >> >
19 >> > 3. Modify eclass, so that it works with path containing spaces inside:
20 >> >
21 >> > -for conffile in ${FONT_CONF[@]}; do
22 >> > +for conffile in "${FONT_CONF[@]}"; do
23 >
24 >> That looks right, although step 1 should *always* be to use the code from
25 >> step 3.
26 >
27 > No. The idea is to have after first step some kind of "backward
28 > compatibility". So while we have
29 >
30 > FONT_CONF="path1 path2"
31 >
32 > definitions in the tree, when I use them as array bash will expand
33 > ${FONT_CONF[@]} in the same way as array with exactly 1 element. And I
34 > do not it to be qouted as for cycle should iterate through path{1,2}. I
35 > know this does not work with spaces, but current implementations has the
36 > same limitation.
37 >
38 OIC. You could use this:
39 isArr() [[ $(declare -p "$1" 2>/dev/null) = 'declare -a'* ]]
40 with a function to carry out the actual task:
41 foo () { local conffile; for conffile; do .."$conffile".. ; done; }
42 if isArr FONT_CONF; then
43 foo "${FONT_CONF[@]}"
44 else foo $FONT_CONF
45 fi || die "Unable to foo ${FONT_CONF[*]}"
46
47 - if you want to support both types of config variable. But yeah, your
48 migration path makes sense; sorry for missing that and thanks for your
49 patience.
50
51
52 --
53 gentoo-dev@g.o mailing list