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

Re: read -s doesn't work with -t?



On 16/02/2008, Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
> On 16/02/2008, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
>  > On Feb 15, 10:27pm, Mikael Magnusson wrote:
>  >  } Subject: read -s doesn't work with -t?
>  >
>  > }
>  >  } However, when I
>  >  } give read -s -t 60, the -s seems to be ignored. Bug or feature?
>  >
>  >
>  > This sounds like it may be related to:
>  >
>  >         http://www.zsh.org/mla/workers/2008/msg00071.html
>  >
>  >  That thread just sort of died without resolution because PWS can't
>  >  reproduce the problem.
>
>
> Hmm, weird. For me it happens on both 4.2.5 and 4.3.4/5, and I've
>  tried sshing to all machines I have access to with zsh, and it is the
>  same on all of them. Even found a 4.2.3-dev1 now that's the same...

Maybe this is overly naive, but the following seems to fix the issue
for me. That is, just moving the code for -s up above the code for -t.
I tried combinations of -t, -s and -k, and they all worked as I
expected after the change.

diff --git a/Src/builtin.c b/Src/builtin.c
index 289e5f3..a2b47da 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -4822,6 +4822,21 @@ bin_read(char *name, char **args, Options ops,
UNUSED(int func))
     } else
 	readfd = izle = 0;

+    if (OPT_ISSET(ops,'s') && SHTTY != -1) {
+	struct ttyinfo ti;
+	gettyinfo(&ti);
+	if (! resettty) {
+	    saveti = ti;
+	    resettty = 1;
+	}
+#ifdef HAS_TIO
+	ti.tio.c_lflag &= ~ECHO;
+#else
+	ti.sgttyb.sg_flags &= ~ECHO;
+#endif
+	settyinfo(&ti);
+    }
+
     if (OPT_ISSET(ops,'t')) {
 	zlong timeout = 0;
 	if (OPT_HASARG(ops,'t')) {
@@ -4882,20 +4897,6 @@ bin_read(char *name, char **args, Options ops,
UNUSED(int func))
 	    settyinfo(&ti);
 	}
     }
-    if (OPT_ISSET(ops,'s') && SHTTY != -1) {
-	struct ttyinfo ti;
-	gettyinfo(&ti);
-	if (! resettty) {
-	    saveti = ti;
-	    resettty = 1;
-	}
-#ifdef HAS_TIO
-	ti.tio.c_lflag &= ~ECHO;
-#else
-	ti.sgttyb.sg_flags &= ~ECHO;
-#endif
-	settyinfo(&ti);
-    }

     /* handle prompt */
     if (firstarg) {

-- 
Mikael Magnusson



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