From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3675 invoked from network); 30 Jan 2004 00:24:08 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 30 Jan 2004 00:24:08 -0000 Received: (qmail 5693 invoked by alias); 30 Jan 2004 00:23:27 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7030 Received: (qmail 5673 invoked from network); 30 Jan 2004 00:23:26 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 30 Jan 2004 00:23:26 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [216.136.173.132] by sunsite.dk (MessageWall 1.0.8) with SMTP; 30 Jan 2004 0:23:25 -0000 Message-ID: <20040130002324.3439.qmail@web12405.mail.yahoo.com> Received: from [64.241.135.40] by web12405.mail.yahoo.com via HTTP; Thu, 29 Jan 2004 16:23:24 PST Date: Thu, 29 Jan 2004 16:23:24 -0800 (PST) From: Bob Schmertz Reply-To: robert.schmertz@terpalum.umd.edu Subject: Re: Positional parameters with more than one space To: David "Gómez" , Zsh-users In-Reply-To: <20040129225017.GA9097@fargo> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii --- David Gómez wrote: > Hi all ;), > > I'm coding a shell function that receives several files as parameters. > These > files usually will have spaces in its names, so i want this function to > work correctly with spaces. > > I'm using the $@ array to iterate thru all parameters, with a for loop: > > for i in "$@"; do > something > done > > And it works fine, except when a file has more that one space in its > name. > I mean, if one of the files is "more than one space", after the $@ > expansion it transforms to "more that one space" which obviously > doesn't > exists. How can i avoid this? > You haven't given us enough info about where the parameters are coming from (i.e., how you're calling your script) or what you're doing with them inside the loop. Here is a complete sample script called check_spaces.zsh: #!/bin/zsh for file in "$@" do /bin/echo $file /bin/echo "$file" done # --end-- If I call it thus: check_spaces.zsh * I get two spaces for a file that has two consecutive spaces in its name. If I run it with bash, however, I get consolidated spaces in the output of the first echo line, without the parameter quoted. In short, I don't know why you're having problems :-) ===== Cheers, Bob Schmertz __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free web site building tool. Try it! http://webhosting.yahoo.com/ps/sb/