1 |
On Saturday 01 August 2009 11:22:41 Steven J Long wrote: |
2 |
> Mike Frysinger wrote: |
3 |
> > On Tuesday 21 July 2009 06:13:25 Steven J Long wrote: |
4 |
> >> Nikos Chantziaras wrote: |
5 |
> >> > Thanks. I ended up doing it this way, though with only one loop in |
6 |
> >> > src_install(), which seems to be a bit more efficient and shorter: |
7 |
> >> > |
8 |
> >> > |
9 |
> >> > LANGUAGES="de" |
10 |
> >> > for i in ${LANGUAGES}; do |
11 |
> >> > IUSE="${IUSE} linguas_${i}" |
12 |
> >> > done |
13 |
> >> |
14 |
> >> Just on a side-note (not saying it's how you want to do this one), this |
15 |
> >> is something that BASH arrays are nice for (saving another loop): |
16 |
> >> $ foo=(bar baz quux) |
17 |
> >> $ echo "prefixed: '${foo[*]/#/pfx_}'" |
18 |
> >> prefixed: 'pfx_bar pfx_baz pfx_quux' |
19 |
> > |
20 |
> > printf would probably be better as it is typically a shell builtin and it |
21 |
> > doesnt require use of arrays/uncommon syntax. |
22 |
> > media-gfx/exiv2/exiv2-0.18.ebuild: |
23 |
> > IUSE_LINGUAS="de es fi fr pl ru sk" |
24 |
> > IUSE="${IUSE} $(printf 'linguas_%s ' ${IUSE_LINGUAS})" |
25 |
> |
26 |
> Doh, forgot about printf. (We have alias print="printf '%s\n'" in our lib |
27 |
> code which comes in handy too.) Nice one. |
28 |
> |
29 |
> The only issue with the above is that it requires a subshell; forking isn't |
30 |
> cheap (especially on Interix/cygwin/doze) and in general it's considered a |
31 |
> bit lame (at least amongst the ##bash old-timers that I bump heads with) to |
32 |
> need forking in BASH, though ofc not in SH, which is why it might not be |
33 |
> the best here, since the metadata generation phase is a restricted subset |
34 |
> of SH, leave alone BASH, at least aiui. |
35 |
|
36 |
forks are cheap on any sane *nix box, and subshells/builtins are better than |
37 |
external programs. i'm pretty sure the overhead here tends to be less than |
38 |
the overhead of running for loops, especially as the LINGUAS gets bigger. |
39 |
-mike |