1 |
On Dec 11, 2007 8:17 AM, Peter Volkov <pva@g.o> wrote: |
2 |
|
3 |
> Hello. |
4 |
> |
5 |
> Some eclasses (kernel-2, font) use variable to pass space separated PATH |
6 |
> to patch or fontconfig files from ebuild to eclass. In ebuild we use: |
7 |
> |
8 |
> FONT_CONF="path1 path2" |
9 |
> |
10 |
> Then eclasses use the variable: |
11 |
> |
12 |
> for conffile in ${FONT_CONF}; do |
13 |
> ... |
14 |
> done |
15 |
> |
16 |
> The problem with this doesn't work if path{1,2} contain spaces. The |
17 |
> solution I'm thinking about is to you arrays: |
18 |
> |
19 |
> FONT_CONF=("path1" "path2") |
20 |
> |
21 |
> for conffile in "${FONT_CONF[@]}"; do |
22 |
> ... |
23 |
> done |
24 |
> |
25 |
> But is this good idea? Are there better? |
26 |
> |
27 |
> -- |
28 |
> Peter. |
29 |
> |
30 |
|
31 |
I agree using arrays would be much better, you can also loop through the |
32 |
arrays like. |
33 |
|
34 |
for ((i=0;i<${#FONT_CONF[*]};i++)); do echo "${FONT_CONF[i]}"; done |
35 |
|
36 |
this way you can avoid spacing because you'll just be calling each array |
37 |
element in order using quotes. |
38 |
|
39 |
Fernando |