From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10403 invoked from network); 22 Jul 2005 09:45:13 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 22 Jul 2005 09:45:13 -0000 Received: (qmail 79271 invoked from network); 22 Jul 2005 09:45:06 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 22 Jul 2005 09:45:06 -0000 Received: (qmail 9000 invoked by alias); 22 Jul 2005 09:44:59 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 9124 Received: (qmail 8991 invoked from network); 22 Jul 2005 09:44:58 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 22 Jul 2005 09:44:58 -0000 Received: (qmail 77940 invoked from network); 22 Jul 2005 09:44:58 -0000 Received: from mailhost1.csr.com (HELO MAILSWEEPER01.csr.com) (81.105.217.43) by a.mx.sunsite.dk with SMTP; 22 Jul 2005 09:44:52 -0000 Received: from exchange03.csr.com (unverified [10.100.137.60]) by MAILSWEEPER01.csr.com (Content Technologies SMTPRS 4.3.12) with ESMTP id for ; Fri, 22 Jul 2005 10:42:47 +0100 Received: from news01.csr.com ([10.103.143.38]) by exchange03.csr.com with Microsoft SMTPSVC(5.0.2195.6713); Fri, 22 Jul 2005 10:46:57 +0100 Received: from news01.csr.com (localhost.localdomain [127.0.0.1]) by news01.csr.com (8.13.1/8.12.11) with ESMTP id j6M9in79024257 for ; Fri, 22 Jul 2005 10:44:49 +0100 Received: from csr.com (pws@localhost) by news01.csr.com (8.13.1/8.13.1/Submit) with ESMTP id j6M9imqY024254 for ; Fri, 22 Jul 2005 10:44:49 +0100 Message-Id: <200507220944.j6M9imqY024254@news01.csr.com> X-Authentication-Warning: news01.csr.com: pws owned process doing -bs To: zsh-users@sunsite.dk Subject: Re: Help with paths and file sorting In-reply-to: References: <20050721222024.GA14060@fast.vc.shawcable.net> Date: Fri, 22 Jul 2005 10:44:47 +0100 From: Peter Stephenson X-OriginalArrivalTime: 22 Jul 2005 09:46:57.0416 (UTC) FILETIME=[4CCB3880:01C58EA2] X-Spam-Checker-Version: SpamAssassin 3.0.4 (2005-06-05) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.0.4 J wrote: > Suppose you have an array "files" that contain the names of the files > you want to sort. > You can just go along the lines of > tmp=\(\(${(pj:|:)files}\)\) > files=(${~tmp}()) >... > But there is a caveat : > If one of the filenames have a character in it that can be interpreted > as a pattern for globbing, it will, and that's not what you want. A > solution to that is to quote the ${files} array with a (q) flag, but > then spaces in filenames (or any other special char for that) would be > quoted too in the ${tmp} array, meaning they won't match themselves > because these quotes are not going to be removed by the ${~tmp} > construct :/ You can get around this by using eval instead of ~. eval files="(("${(j.|.)${(q)files}}")())" That's safe because the only part you're not directly in control of, $files, is fully quoted. It's probably best if includes N for nullglob so that the resulting files array is empty if nothing matches. -- Peter Stephenson Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070 ********************************************************************** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. **********************************************************************