zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: [PATCH] Re: Quick local CVS change scan, and bug in read?
Date: Mon, 20 May 2013 22:56:15 -0700	[thread overview]
Message-ID: <CAH+w=7aQJDL=4vgGod=RpzmYZGWukw31oKRFJE29ME=ngaVrrQ@mail.gmail.com> (raw)

[-- 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


                 reply	other threads:[~2013-05-21  5:56 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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='CAH+w=7aQJDL=4vgGod=RpzmYZGWukw31oKRFJE29ME=ngaVrrQ@mail.gmail.com' \
    --to=schaefer@brasslantern.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).