1 |
On Tuesday 11 December 2007 08:17:12 Peter Volkov wrote: |
2 |
> Some eclasses (kernel-2, font) use variable to pass space separated PATH |
3 |
> to patch or fontconfig files from ebuild to eclass. In ebuild we use: |
4 |
> |
5 |
> FONT_CONF="path1 path2" |
6 |
> |
7 |
> Then eclasses use the variable: |
8 |
> |
9 |
> for conffile in ${FONT_CONF}; do |
10 |
> ... |
11 |
> done |
12 |
> |
13 |
> The problem with this doesn't work if path{1,2} contain spaces. The |
14 |
> solution I'm thinking about is to you arrays: |
15 |
> |
16 |
> FONT_CONF=("path1" "path2") |
17 |
> |
18 |
> for conffile in "${FONT_CONF[@]}"; do |
19 |
> ... |
20 |
> done |
21 |
> |
22 |
> But is this good idea? Are there better? |
23 |
|
24 |
FONT_CONF=path1:path2 |
25 |
|
26 |
IFS=. |
27 |
for for conffile in ${FONT_CONF}; do |
28 |
.... |
29 |
done |
30 |
unset IFS |
31 |
|
32 |
Or if you want to be really picky about preserving IFS if you can't make it |
33 |
local in a function |
34 |
|
35 |
SIFS=${IFS-y} OIFS=${IFS} |
36 |
IFS=. |
37 |
for for conffile in ${FONT_CONF}; do |
38 |
.... |
39 |
done |
40 |
if [ "${SIFS}" = "y" ]; then |
41 |
unset IFS |
42 |
else |
43 |
IFS=${OIFS} |
44 |
fi |
45 |
|
46 |
That way you work the same way as the classic $PATH variable. |
47 |
|
48 |
But of course no one cares as it's Just Not Bash (tm) |
49 |
|
50 |
Thanks |
51 |
|
52 |
Roy |
53 |
-- |
54 |
gentoo-dev@g.o mailing list |