Gentoo Archives: gentoo-dev

From: Matthias Schwarzott <zzam@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] Re: RFC: qemu -> add gcc-3.x dependency
Date: Sat, 10 May 2008 08:10:07
Message-Id: 200805101010.00352.zzam@gentoo.org
In Reply to: [gentoo-dev] Re: RFC: qemu -> add gcc-3.x dependency by Steve Long
1 On Samstag, 10. Mai 2008, Steve Long wrote:
2 > Matthias Schwarzott wrote:
3 > > Code may look like this:
4 > >
5 > > # get last one of sorted list
6 > > for t in $(ls -1 /usr/bin/gcc-3*|sort); do
7 >
8 > use teh globs, luke ;)
9 > for t in /usr/bin/gcc-3*; do # will already do this, sorting according to
10 > LC_COLLATE order (set to C or POSIX [same thing] for ebuild.) There's no
11 > need to step through every one either:
12 > t=(/usr/bin/gcc-3*); p=${t[@]: -1}; unset t # get rid of array storage
13 > (using same var for both, eg t=${t[@]: -1} only sets the first cell; the
14 > rest of the array is still live. var is a synonym for var[0] in BASH.)
15 >
16 > set -- *
17 > t=${@: -1} # works here as well but dunno if that applies to all sh (the -1
18 > expansion, not the set.) In any event not needed in BASH since arrays make
19 > our life so much easier ;)
20 >
21 Well, you want it compact, without loops.
22 Here is it:
23
24 set -- /usr/bin/gcc-3*
25 Get first entry: CC="$1"
26 Get last entry: eval CC="\${$#}"
27
28 Regards
29 Matthias
30 --
31 gentoo-dev@l.g.o mailing list

Replies

Subject Author
[gentoo-dev] Re: Re: RFC: qemu -> add gcc-3.x dependency Steve Long <slong@××××××××××××××××××.uk>