Gentoo Archives: gentoo-project

From: Steve Long <slong@××××××××××××××××××.uk>
To: gentoo-project@l.g.o
Subject: [gentoo-project] Re: Re: Re: New developer: Ron Gemeinhardt (timebandit)
Date: Tue, 30 Sep 2008 07:00:04
Message-Id: gbsioo$pi0$1@ger.gmane.org
In Reply to: Re: [gentoo-project] Re: Re: New developer: Ron Gemeinhardt (timebandit) by Ron Gemeinhardt
1 Ron Gemeinhardt wrote:
2
3 > Steve Long wrote:
4 >> Nirbheek Chauhan wrote:
5 >>> On Fri, Sep 26, 2008 at 2:09 PM, Steve Long
6 >>> <slong@××××××××××××××××××.uk> wrote:
7 >>>> Nirbheek Chauhan wrote:
8 >>>>> $(for ACRONYM in ${LinkedIn}; do echo -en "${ACRONYM},"; done; echo
9 >>>>> -ne '\b')
10 >>>>>
11 >>>> Now that *is* fail ;-)
12 >>> Crap! I forgot, \b only works for displaying in the terminal; doesn't
13 >>> actually "backspace" :(
14 >>>
15 >> Eh works well enough for display (not file as you mentioned) ... <snip>
16 >
17 > Gentlemen, please...can we talk about me for a minute?
18 > Though entertaining, this byplay eats into my allotted fifteen minutes of
19 > fame. ;-)
20 >
21 LMAO.
22
23 > Besides, you really want something like:
24 >
25 Heh, you had to go there.. I think you'll fit right in ;-)
26
27 > echo "knowledge of $(unset last; for ACRONYM in ${LinkedIn[*]};
28 > do echo -n ${last:+,}$arg; last=$arg; done)."
29 >
30 > But I wasn't recruited to be a ebuild dev (Calchan would add, "yet") so I
31 > won't point that out.
32 >
33 That's good ;p as all that does is what:
34 (IFS=,; echo "Knowledge of: ${LinkedIn[*]}")
35 ..does, only not as elegantly (tho I don't like the subshell) nor is it
36 actually correct; quite apart from the typo, it will split on any
37 whitespace, not array members (which can be _any_ string). If you want to
38 iterate over an array, use: for foo in "${array[@]}"
39
40 Another good one is: printf '%s\n' "${array[@]}"
41
42 NB: without quotes, there's no difference between ${array[@]} and
43 ${array[*]}. They will both be treated as a string split into parameters
44 according to IFS (space, tab and newline by default; unset IFS only uses
45 space.) This is similar to: echo $foo vs: echo "$foo"
46
47 Quotes around the * form gives a single string, with each array member
48 separated by the first char of IFS (space by default or if unset, use IFS=
49 to get no separator.) Quotes around the @ form gives every member as a
50 separate parameter (which is what you pretty much always want, except for
51 display.)
52
53 > Thanks to all for the warm welcome! I promise to do my best to moderate
54 > the forums in the capricious, arbitrary and inscrutable--err, I mean, fair
55 > and balanced--manner to which we're all accustomed.
56 >
57 Glad to hear it, I've often thought the Forums should be more like Fox in
58 proselytising The Gentoo Way?.. *runs*