From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([69.77.167.62] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1Jujn7-0004Z9-KV for garchives@archives.gentoo.org; Sat, 10 May 2008 07:46:49 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 73451E054C; Sat, 10 May 2008 07:46:19 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 4BA4DE054C for ; Sat, 10 May 2008 07:46:19 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id EA4DB66B3B for ; Sat, 10 May 2008 07:46:18 +0000 (UTC) X-Virus-Scanned: amavisd-new at gentoo.org X-Spam-Score: -0.773 X-Spam-Level: X-Spam-Status: No, score=-0.773 required=5.5 tests=[AWL=0.759, BAYES_00=-2.599, RCVD_IN_DNSWL_LOW=-1, RCVD_NUMERIC_HELO=2.067] Received: from smtp.gentoo.org ([127.0.0.1]) by localhost (smtp.gentoo.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id IvSr0a3teUNu for ; Sat, 10 May 2008 07:46:12 +0000 (UTC) Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTP id 24A4B66C5F for ; Sat, 10 May 2008 07:46:09 +0000 (UTC) Received: from list by ciao.gmane.org with local (Exim 4.43) id 1JujmN-0000I9-DW for gentoo-dev@gentoo.org; Sat, 10 May 2008 07:46:03 +0000 Received: from 82.152.208.57 ([82.152.208.57]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 10 May 2008 07:46:03 +0000 Received: from slong by 82.152.208.57 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 10 May 2008 07:46:03 +0000 X-Injected-Via-Gmane: http://gmane.org/ To: gentoo-dev@lists.gentoo.org From: Steve Long Subject: [gentoo-dev] Re: RFC: qemu -> add gcc-3.x dependency Date: Sat, 10 May 2008 08:42:40 +0100 Message-ID: References: <20080504194830.GD6914@nibiru.local> <1209988986.31591.11.camel@camobap> <200805051846.17975.zzam@gentoo.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 82.152.208.57 User-Agent: KNode/0.10.9 Sender: news X-Archives-Salt: fa9fb13e-ff95-4e54-88d2-14e81db670cb X-Archives-Hash: 45bac8593a3c03d59eb7a4a86c0ba947 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 ;) cf: /msg greybot ls and http://wooledge.org/mywiki/glob -- remember you can do, eg: for i in portage/*/*foo*/*.ebuild or a more common example: for f in */*/.jpg It's not find, but it is efficient and filename-safe. Regards, steveL. (Please, no complaints about not using spaces in filenames, there's no telling where your script could be used-- if it's written correctly. Subshells and externals as well; why fork and waste resources we don't have to?) -- gentoo-dev@lists.gentoo.org mailing list