From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27074 invoked from network); 25 Apr 2005 10:15:10 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 25 Apr 2005 10:15:10 -0000 Received: (qmail 65317 invoked from network); 25 Apr 2005 10:15:04 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 25 Apr 2005 10:15:04 -0000 Received: (qmail 20198 invoked by alias); 25 Apr 2005 10:14:54 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 8752 Received: (qmail 20181 invoked from network); 25 Apr 2005 10:14:53 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 25 Apr 2005 10:14:53 -0000 Received: (qmail 64029 invoked from network); 25 Apr 2005 10:14:53 -0000 Received: from mailhost1.csr.com (HELO MAILSWEEPER01.csr.com) (81.105.217.43) by a.mx.sunsite.dk with SMTP; 25 Apr 2005 10:14:48 -0000 Received: from exchange03.csr.com (unverified [10.100.137.60]) by MAILSWEEPER01.csr.com (Content Technologies SMTPRS 4.3.12) with ESMTP id ; Mon, 25 Apr 2005 11:13:06 +0100 Received: from news01.csr.com ([10.103.143.38]) by exchange03.csr.com with Microsoft SMTPSVC(5.0.2195.6713); Mon, 25 Apr 2005 11:15:13 +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 j3PAEoHg010903; Mon, 25 Apr 2005 11:14:50 +0100 Received: from csr.com (pws@localhost) by news01.csr.com (8.13.1/8.13.1/Submit) with ESMTP id j3PAEoF5010900; Mon, 25 Apr 2005 11:14:50 +0100 Message-Id: <200504251014.j3PAEoF5010900@news01.csr.com> X-Authentication-Warning: news01.csr.com: pws owned process doing -bs To: Mariusz Gniazdowski , zsh-users@sunsite.dk Subject: Re: while read; problems In-reply-to: <20050422122206.GA11327@globtel.pl> References: <20050422122206.GA11327@globtel.pl> Date: Mon, 25 Apr 2005 11:14:50 +0100 From: Peter Stephenson X-OriginalArrivalTime: 25 Apr 2005 10:15:13.0992 (UTC) FILETIME=[ABAE2C80:01C5497F] X-Spam-Checker-Version: SpamAssassin 3.0.2 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, score=-2.6 required=6.0 tests=AWL,BAYES_00 autolearn=ham version=3.0.2 X-Spam-Hits: -2.6 Mariusz Gniazdowski wrote: > function count { > local line max=0 idx=0 maxidx=0 > while read line; do > line=${#line} > (( idx++ )) > [[ $max -lt $line ]] && { max=$line; maxidx=$idx; } > done < "$1" > echo "$max in line nr: $maxidx" > } > > Second problem: zsh results differ from run to run. I had results like: > 6097 in line nr: 169 > 6553 in line nr: 300 > etc. Luckily, with debugging turned on, this output an error message so I could find it without too much trouble. It's yet another problem with Meta characters. (If this doesn't fix it report it again.) Note that the bug turned up in the code which strips trailing whitespace from the line. This is the correct behaviour, but it's a not clear it's what you want in a binary file. You may need to set IFS to empty, as DervishD mentioned. Further discussion on the bug should go to zsh-workers. Index: Src/builtin.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v retrieving revision 1.136 diff -u -r1.136 builtin.c --- Src/builtin.c 9 Mar 2005 17:14:06 -0000 1.136 +++ Src/builtin.c 25 Apr 2005 10:09:21 -0000 @@ -4747,8 +4747,17 @@ } signal_setmask(s); } - while (bptr > buf && iwsep(bptr[-1])) - bptr--; + while (bptr > buf) { + if (bptr > buf + 1 && bptr[-2] == Meta) { + if (iwsep(bptr[-1] ^ 32)) + bptr -= 2; + else + break; + } else if (iwsep(bptr[-1])) + bptr--; + else + break; + } *bptr = '\0'; if (resettty && SHTTY != -1) settyinfo(&saveti); -- 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. **********************************************************************