From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19453 invoked by alias); 28 Aug 2011 16:50:26 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 29731 Received: (qmail 21525 invoked from network); 28 Aug 2011 16:50:24 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 Received-SPF: neutral (ns1.primenet.com.au: 74.125.82.43 is neither permitted nor denied by SPF record at ntlworld.com) X-ProxyUser-IP: 81.97.71.129 Date: Sun, 28 Aug 2011 17:50:14 +0100 From: Peter Stephenson To: zsh-workers@zsh.org Subject: Re: Is "read -AE" buggy? Message-ID: <20110828175014.7750a85e@pws-pc.ntlworld.com> In-Reply-To: <110823001827.ZM19096@torch.brasslantern.com> References: <110823001827.ZM19096@torch.brasslantern.com> X-Mailer: Claws Mail 3.7.9 (GTK+ 2.24.4; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Tue, 23 Aug 2011 00:18:27 -0700 Bart Schaefer wrote: > schaefer<535> wc config.modules | read -AE foo > 64 > 461 > 4569 > config.modules > 64 > 461 > 4569 > config.modules I think this is down to the fact that bin_read() is a complete mess where people dump in new features without any attempt to impose structure (fancy that happening in zsh...) so the obvious fix is as good as any. We can at least test this, although in general getting this sort of thing right with read is (at least) a quadratic problem. Index: Src/builtin.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v retrieving revision 1.252 diff -p -u -r1.252 builtin.c --- Src/builtin.c 3 Jun 2011 19:54:44 -0000 1.252 +++ Src/builtin.c 28 Aug 2011 16:46:33 -0000 @@ -5549,7 +5549,7 @@ bin_read(char *name, char **args, Option *bptr = '\0'; #endif /* dispose of word appropriately */ - if (OPT_ISSET(ops,'e') || OPT_ISSET(ops,'E')) { + if (OPT_ISSET(ops,'e')) { zputs(buf, stdout); putchar('\n'); } @@ -5581,7 +5581,7 @@ bin_read(char *name, char **args, Option : (char **)zalloc((al + 1) * sizeof(char *))); for (pp = p, n = firstnode(readll); n; incnode(n)) { - if (OPT_ISSET(ops,'e') || OPT_ISSET(ops,'E')) { + if (OPT_ISSET(ops,'E')) { zputs((char *) getdata(n), stdout); putchar('\n'); } Index: Test/B04read.ztst =================================================================== RCS file: /cvsroot/zsh/zsh/Test/B04read.ztst,v retrieving revision 1.5 diff -p -u -r1.5 B04read.ztst --- Test/B04read.ztst 7 Jan 2011 10:05:35 -0000 1.5 +++ Test/B04read.ztst 28 Aug 2011 16:46:33 -0000 @@ -93,3 +93,20 @@ read foo) <<one +>two +>three +>one:two:three + + array=() + read -Ae array <<<'four five six' + print ${(j.:.)array} +0:Behaviour of -A and -e combination +>four +>five +>six +> -- Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/