Gentoo Archives: gentoo-dev

From: Roy Marples <uberlord@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in x11-libs/qt: ChangeLog qt-4.3.2.ebuild
Date: Thu, 04 Oct 2007 07:01:17
Message-Id: 1191480544.2542.5.camel@uberpc.marples.name
In Reply to: [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in x11-libs/qt: ChangeLog qt-4.3.2.ebuild by Steve Long
1 On Thu, 2007-10-04 at 05:03 +0100, Steve Long wrote:
2 > Donnie Berkholz wrote:
3 >
4 > > spec=$(echo ${CHOST} | cut -d- -f3)
5 > >
6 > You can do this without resort to an external process:
7 > IFS=-
8 > read _ _ spec _ <<< "$CHOST"
9 > unset IFS
10 > - or you can do:
11 > IFS=-
12 > arr=($CHOST)
13 > unset IFS
14 > spec=${arr[2]}
15
16 See, another use of bash arrays just because you can?
17 IFS=-
18 set -- ${CHOST}
19 spec=$2
20
21 Works fine in bash - and other shells.
22
23 You need to preserve IFS when changing it, however. Unless of course,
24 you're doing this in a function so you can just local IFS=-
25
26 Here's a snippet from b2's localmount init script.
27
28 IFS=${IFS} SIFS=${IFS-y}
29 FS=$IFS:
30 for x in ${NO_UMOUNTS} ${RC_NO_UMOUNTS} ; do
31 no_umounts="${no_umounts}|${x}"
32 one
33 if [ "${SIFS}" = "y" ] ; then
34 IFS=$OIFS
35 else
36 unset IFS
37 fi
38
39 Thanks
40
41 Roy
42
43 --
44 gentoo-dev@g.o mailing list

Replies