zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: zsh-workers@zsh.org
Subject: Re: Is "read -AE" buggy?
Date: Sun, 28 Aug 2011 17:50:14 +0100	[thread overview]
Message-ID: <20110828175014.7750a85e@pws-pc.ntlworld.com> (raw)
In-Reply-To: <110823001827.ZM19096@torch.brasslantern.com>

On Tue, 23 Aug 2011 00:18:27 -0700
Bart Schaefer <schaefer@brasslantern.com> 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) <<<bar
 1:return status on failing to set parameter
 ?(eval):2: read-only variable: foo
+
+  read -AE array <<<'one two three'
+  print ${(j.:.)array}
+0:Behaviour of -A and -E combination
+>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 <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


  reply	other threads:[~2011-08-28 16:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-23  7:18 Bart Schaefer
2011-08-28 16:50 ` Peter Stephenson [this message]
2011-08-29 15:26   ` Bart Schaefer
2011-08-29 17:06     ` Peter Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110828175014.7750a85e@pws-pc.ntlworld.com \
    --to=p.w.stephenson@ntlworld.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).