From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14155 invoked from network); 5 Aug 2005 10:50:24 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 5 Aug 2005 10:50:24 -0000 Received: (qmail 53574 invoked from network); 5 Aug 2005 10:50:17 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 5 Aug 2005 10:50:17 -0000 Received: (qmail 16951 invoked by alias); 5 Aug 2005 10:50:10 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 9241 Received: (qmail 16941 invoked from network); 5 Aug 2005 10:50:09 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 5 Aug 2005 10:50:09 -0000 Received: (qmail 52490 invoked from network); 5 Aug 2005 10:50:09 -0000 Received: from caly80.spider.com (HELO bifrost.spider.com) (194.217.109.12) by a.mx.sunsite.dk with SMTP; 5 Aug 2005 10:50:02 -0000 Received: from no.name.available by bifrost.spider.com via smtpd (for [130.225.247.86]) with SMTP; 5 Aug 2005 10:50:01 UT Received: from heimdall-dmz.spider.com (mailhub.spider.com [212.240.99.13]) by caly80.spider.com (Postfix) with SMTP id A710B6F5C; Fri, 5 Aug 2005 11:49:58 +0100 (BST) Received: from mailhub.spider.com by heimdall-dmz.spider.com via smtpd (for [172.16.254.22]) with SMTP; 5 Aug 2005 10:49:55 UT Received: from localhost (duey.spider.com [212.240.99.128]) by batistuta.spider.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id 3KAPHSJL; Fri, 5 Aug 2005 11:41:31 +0100 Date: Fri, 5 Aug 2005 11:47:33 +0100 From: Stephane CHAZELAS To: Meino Christian Cramer Cc: duvall@comfychair.org, zsh-users@sunsite.dk Subject: Re: Sorting files Message-ID: <20050805104732.GA16537@artesyncp.com> Mail-Followup-To: Meino Christian Cramer , duvall@comfychair.org, zsh-users@sunsite.dk References: <20050804.211050.78707635.Meino.Cramer@gmx.de> <20050804191816.GI18173@lorien.comfychair.org> <20050804204122.GA6174@sc> <20050805.050146.74727615.Meino.Cramer@gmx.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050805.050146.74727615.Meino.Cramer@gmx.de> User-Agent: Mutt/1.5.7i X-Spam-Checker-Version: SpamAssassin 3.0.4 (2005-06-05) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00 autolearn=ham version=3.0.4 On Fri, Aug 05, 2005 at 05:01:46AM +0200, Meino Christian Cramer wrote: [...] > > > print -l **/*(.oL) [...] > > Should be: > > > > print -rl -- **/*(.oL) [...] > This gave me no sorted output...sorry :O) I was just pointing out that print -l arbitrary list of file names is not correct. print without -r is to print a text that is in the form "text with \t \n... escape sequences" like in C string constants. That's an old design error in shells inherited from ksh to have that as the default behavior. For a correct way, see perl for instance where \t, \n are expanded at the language level (or by the double quotes if you like). In perl, $var = "\t" assigns a character to $var and print $var prints the content of $var. ($var = '\t' assigns "\" and "t" to $var). In shells, var="\t" assigns the "\" and "t" characters to $var and print "$var" prints the expansion of the "\t" escape sequence, i.e. a character. ksh93, bash and zsh have the cumbersome: var=$'\t' that does the same as perl's "\t", but print (and echo) are still /broken/ and need the "-r" (and -n to prevent adding a newline character) to print strings asis. Without --, the list can be options or arguments, while you definitely mean them to be arguments there. Another annoying thing with print -l is that without arguments, it still prints an empty line as if it had been given an empty argument. So that to print arguments one per line, you actually need: correct_print-l() { (( $# == 0 )) || print -rl -- "$@" } or to be portable (POSIX): correct_print_l() { [ "$#" -eq 0 ] || printf '%s\n' "$@" } -- Stephane