zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] Re: Quick local CVS change scan, and bug in read?
@ 2013-05-21  5:56 Bart Schaefer
  0 siblings, 0 replies; only message in thread
From: Bart Schaefer @ 2013-05-21  5:56 UTC (permalink / raw)
  To: Zsh hackers list

[-- Attachment #1: Type: text/plain, Size: 848 bytes --]

On Sat, May 18, 2013 at 4:24 PM, Bart Schaefer
<schaefer@brasslantern.com> wrote:
> some CVS/Entries files end with the line "D" with none of the usual
> field-separator slashes.  When the "while IFS=/ read ..." loop
> encounters such a line, it assigns type=D but leaves name, version,
> date, flags, and branch set to their existing values from the previous
> loop pass.  I'm pretty sure this is wrong; bash read assigns empty
> string to all the "unused" variables in the list.

The bug turned out to be very easy to fix.  The reason it went
unnoticed for so long is, the variables were correctly cleared when
bin_read reached EOF.

I generally don't like attaching patches rather than in-lining them,
but I'm still stuck with gmail for the nonce and it tends to mangle
patches in-line, so I'm going to try attaching this one.  It's very
short.

[-- Attachment #2: 0001-upon-read-of-a-short-line-assign-all-variables-passe.patch --]
[-- Type: application/octet-stream, Size: 894 bytes --]

From 19b49db7a31387b65548167f73aeabbbbe60c3ab Mon Sep 17 00:00:00 2001
From: Barton Schaefer <schaefer@zsh.org>
Date: Mon, 20 May 2013 22:44:03 -0700
Subject: [PATCH] upon "read" of a short line, assign all variables passed as arguments.

It was noted that (print 1 2 | read one two three four) assigned values
only to $one and $two except in the case where EOF was reached.
---
 Src/builtin.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/Src/builtin.c b/Src/builtin.c
index cd88643..bc91578 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -5674,7 +5674,7 @@ bin_read(char *name, char **args, Options ops, UNUSED(int func))
 	    zputs(buf, stdout);
 	    putchar('\n');
 	}
-	if (!OPT_ISSET(ops,'e') && (*buf || first)) {
+	if (!OPT_ISSET(ops,'e') && (*buf || first || gotnl)) {
 	    if (OPT_ISSET(ops,'A')) {
 		addlinknode(readll, buf);
 		al++;
-- 
1.7.0.4


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2013-05-21  5:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-21  5:56 [PATCH] Re: Quick local CVS change scan, and bug in read? Bart Schaefer

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).