From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9257 invoked from network); 26 May 2004 08:57:00 -0000 Received: from thor.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.86) by ns1.primenet.com.au with SMTP; 26 May 2004 08:57:00 -0000 Received: (qmail 353 invoked from network); 26 May 2004 08:56:21 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 26 May 2004 08:56:21 -0000 Received: (qmail 26706 invoked by alias); 26 May 2004 08:56:10 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7478 Received: (qmail 26691 invoked from network); 26 May 2004 08:56:09 -0000 Received: from thor.dotsrc.org (HELO a.mx.sunsite.dk) (qmailr@130.225.247.86) by sunsite.dk with SMTP; 26 May 2004 08:56:06 -0000 Received: (qmail 32062 invoked from network); 26 May 2004 08:56:06 -0000 Received: from adsl-63-193-117-152.dsl.snfc21.pacbell.net (63.193.117.152) by a.mx.sunsite.dk with SMTP; 26 May 2004 08:56:04 -0000 Received: from iridescent.org ([192.168.0.7] ) by adsl-63-193-117-152.dsl.snfc21.pacbell.net (AppleShare IP Mail Server 6.3.1) id 129479 via TCP with SMTP; Wed, 26 May 2004 01:56:03 -0700 Mime-Version: 1.0 Message-Id: Date: Wed, 26 May 2004 01:55:52 -0700 To: zsh-users@sunsite.dk From: pleb@iridescent.org Subject: Problems with for loops and : modifiers Content-Type: text/plain; charset="us-ascii" X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, hits=0.2 required=6.0 tests=BAYES_50,NO_REAL_NAME autolearn=no version=2.63 X-Spam-Hits: 0.2 I'm having problems doing something that should be simple. I want to iterate over a set of files in a directory and run some commands on those files. In the command I would like to strip the suffix of a filename away (ie basename) and add a new suffix. I can do this interactively in zsh, using several of the different builtin "for" commands, but not in the following shell script. Q: 1. Why do the "for" loops work interactively and get a syntax error in a script? To me a newline terminator is a newline terminator. 2. Maybe I have the sense of SHORT_LOOPS backward? 3. Why does the :r modifier work interactively and not in a script? 4. What are the suggested ways to do what I want to do? zsh script follows. Thanks in advance. leb #/bin/zsh echo "one" #files get echoed but :r is broken for i in *.h; { echo $i:r ; } echo "two" #file get echoed, but :r is broken for i in *.h do echo ${i}:r done echo "three" # works perfectly when run interactively but gets an error in a script #for i (*.h) echo $i:r echo "four" # works perfectly when run interactively but gets an error in a script #foreach i ( *.h) #echo $i:r #end # -- Lawrence E. Bakst pleb@iridescent.org