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

Bugs with read -q

It was pointed out to me that there are bugs with `read -q' (actually
the first one below was pointed out to me and the rest are just

1) `read -q' and `read -k' non-interactively screw up the terminal:
potentially any stty setting, by the looks of things.  It looks to me
like it was trying to restore the tty setting without having the right
settings to restore.  The patch appears to fix it.  Unfortunately the
same problem didn't occur for the version of 2.6-beta11-test11 I was
running, which is very strange as it was in a previous version of
2.6-beta11-test10 and even a version of 2.5: maybe it was fixed by a
patch I applied not yet in the archive.

2) `read -q' interprets typeahead as `n'.  `read -k' works correctly,
i.e. you get the right character.  This may be intentional for cases
like spell checking where getquery() is also used (we've even had a
discussion about it before, but I can't remember the result).  For `read
-q' it should either be documented or changed.

3) It seems to me there's rather too much duplication in bin_read()
between `read -k' and `read -q'.  Probably these should be combined
into a subroutine which also replaces getquery().

I think someone had go at improving bits of read not long ago, perhaps
they can do something about the last two.  This has got all my least
favourite features and I don't feel like trying myself.

*** Src/builtin.c.ti	Tue Nov  7 09:48:32 1995
--- Src/builtin.c	Wed Nov  8 16:36:58 1995
*** 4615,4620 ****
--- 4615,4622 ----
  	    return 1;
+ 	if (!isset(INTERACTIVE))
+ 	    gettyinfo(&shttyinfo);
  	/* sort out the number of characters to read */
  	if (*args && idigit(**args)) {
  	    if (!(nchars = atoi(*args)))
*** 4804,4809 ****
--- 4806,4813 ----
  	    return 1;
+ 	if (!isset(INTERACTIVE))
+ 	    gettyinfo(&shttyinfo);
  	/* set up the buffer */
  	readbuf = (char *)zalloc(2);

Peter Stephenson <pws@xxxxxx>       Tel: +49 33762 77366
WWW:  http://www.ifh.de/~pws/       Fax: +49 33762 77330
Deutches Electronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen
DESY-IfH, 15735 Zeuthen, Germany.

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