zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Re: read -q broken on OSX / BSD?
Date: Sun, 06 Jan 2013 10:43:17 -0800	[thread overview]
Message-ID: <130106104317.ZM2414@torch.brasslantern.com> (raw)
In-Reply-To: <CAPzVZKkeEr_oHVkv-mpudxCN=k=sP4PyvyCTofi3+JaP=fJafw@mail.gmail.com>

On Jan 6, 11:06am, Yaniv Aknin wrote:
} Subject: read -q broken on OSX / BSD?
}
} I'm running % read -q, and then typing a single character which
} isn't y, Y or n. However, the value set in $REPLY isn't n, it is the
} character I typed.

This is apparently version-dependent rather than platform-dependent.
It got changed by workers/27188 back in July 2009, but nobody noticed,
which pretty much tells you that read -q was mainly being used for its
exit status and not for what it returned.

Index: Src/builtin.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v
retrieving revision 1.268
diff -u -r1.268 builtin.c
--- Src/builtin.c	8 Nov 2012 16:50:42 -0000	1.268
+++ Src/builtin.c	6 Jan 2013 18:40:37 -0000
@@ -5490,6 +5490,9 @@
 		eof = 2;
 	    else
 		eof = (bptr - buf != 1 || (buf[0] != 'y' && buf[0] != 'Y'));
+	    buf[0] = eof ? 'n' : 'y';
+	    buf[1] = 0;
+	    bptr = buf+2;
 	}
 	if (OPT_ISSET(ops,'e') || OPT_ISSET(ops,'E'))
 	    fwrite(buf, bptr - buf, 1, stdout);



-- 
Barton E. Schaefer


  reply	other threads:[~2013-01-06 18:43 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-06  9:06 Yaniv Aknin
2013-01-06 18:43 ` Bart Schaefer [this message]
2013-01-06 18:47 ` Peter Stephenson
2013-01-06 22:13   ` Bart Schaefer
2013-01-07  9:47     ` Peter Stephenson
2013-01-07 16:04       ` Bart Schaefer
2013-01-07 21:19         ` 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=130106104317.ZM2414@torch.brasslantern.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).