public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: Matthias Schwarzott <zzam@gentoo.org>
To: gentoo-dev@lists.gentoo.org
Subject: Re: [gentoo-dev]  Re: RFC: qemu -> add gcc-3.x dependency
Date: Sat, 10 May 2008 10:10:00 +0200	[thread overview]
Message-ID: <200805101010.00352.zzam@gentoo.org> (raw)
In-Reply-To: <g03jre$hh$1@ger.gmane.org>

On Samstag, 10. Mai 2008, Steve Long wrote:
> Matthias Schwarzott wrote:
> > Code may look like this:
> >
> > # get last one of sorted list
> > for t in $(ls -1 /usr/bin/gcc-3*|sort); do
>
> use teh globs, luke ;)
> for t in /usr/bin/gcc-3*; do # will already do this, sorting according to
> LC_COLLATE order (set to C or POSIX [same thing] for ebuild.) There's no
> need to step through every one either:
> t=(/usr/bin/gcc-3*); p=${t[@]: -1}; unset t # get rid of array storage
> (using same var for both, eg t=${t[@]: -1} only sets the first cell; the
> rest of the array is still live. var is a synonym for var[0] in BASH.)
>
> set -- *
> t=${@: -1} # works here as well but dunno if that applies to all sh (the -1
> expansion, not the set.) In any event not needed in BASH since arrays make
> our life so much easier ;)
>
Well, you want it compact, without loops.
Here is it:

set -- /usr/bin/gcc-3*
Get first entry: CC="$1"
Get last entry: eval CC="\${$#}"

Regards
Matthias
-- 
gentoo-dev@lists.gentoo.org mailing list



  reply	other threads:[~2008-05-10  8:10 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-04 19:48 [gentoo-dev] RFC: qemu -> add gcc-3.x dependency Enrico Weigelt
2008-05-05 12:03 ` Peter Volkov
2008-05-05 12:24   ` Enrico Weigelt
2008-05-05 16:46   ` Matthias Schwarzott
2008-05-10  7:42     ` [gentoo-dev] " Steve Long
2008-05-10  8:10       ` Matthias Schwarzott [this message]
2008-05-13  1:21         ` [gentoo-dev] " Steve Long
2008-05-05 12:22 ` [gentoo-dev] " Jan Kundrát
2008-05-05 13:37   ` Alon Bar-Lev
2008-05-06 15:34 ` Luca Barbato

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200805101010.00352.zzam@gentoo.org \
    --to=zzam@gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox