Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: read -q broken on OSX / BSD?



On Sun, 6 Jan 2013 11:06:05 +0200
Yaniv Aknin <yaniv@xxxxxxxxxx> wrote:
> 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. The documentation for read -q explicitly says I should expect
> 'n' if the typed character wasn't 'y' or 'Y'.

That does seem to have gone missing.

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

-- 
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/



Messages sorted by: Reverse Date, Date, Thread, Author