Gentoo Archives: gentoo-devhelp

From: Steven J Long <slong@××××××××××××××××××.uk>
To: gentoo-devhelp@l.g.o
Subject: [gentoo-devhelp] Re: Re: LINGUAS vs LANGUAGES
Date: Sat, 01 Aug 2009 15:25:02
Message-Id: 13017217.uNbVpHm14s@news.friendly-coders.info
In Reply to: Re: [gentoo-devhelp] Re: LINGUAS vs LANGUAGES by Mike Frysinger
1 Mike Frysinger wrote:
2
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 An example of BASH saving forking, would be where printf -v comes into play.
37 A more portable, though less flexible command in terms of allowed
38 characters is read from <<< [1]. Though that can be worked round, it's nice
39 not to have to; a shell that is progressing while still retaining excellent
40 portability is useful imo (so long as we don't get our knickers in a twist
41 about using new features, since we can set a required EAPI per-profile in
42 any case.)
43
44 [1] @freenode: /msg greybot <<<
45
46 Yes, I'm aware there are two versions of portability being discussed there.
47 I figured our readership can differentiate, and if not you can always
48 lead 'em gently by the hand to Massachusetts.. ;P
49 --
50 #friendly-coders -- We're friendly but we're not /that/ friendly ;-)

Replies

Subject Author
[gentoo-devhelp] Re: Re: LINGUAS vs LANGUAGES Steven J Long <slong@××××××××××××××××××.uk>
Re: [gentoo-devhelp] Re: Re: LINGUAS vs LANGUAGES Mike Frysinger <vapier@g.o>