Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: No vared in subshells?
- X-seq: zsh-workers 8591
- From: Sven Wischnowsky <wischnow@xxxxxxxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxx
- Subject: Re: No vared in subshells?
- Date: Mon, 8 Nov 1999 13:29:29 +0100 (MET)
- In-reply-to: "Bart Schaefer"'s message of Mon, 8 Nov 1999 04:55:21 +0000
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
Bart Schaefer wrote:
> zagzig[184] (vared -c foo)
> zsh: error on TTY read: bad file descriptor
>
> Why? And shouldn't it at least give a better error message?
As far as I can see it went like this: entersubsh() set `SHTTY = -1'.
Then `getkey()' (caleed from ..., called from `vared') tried to
`read(SHTTY,...)' and that failed of course with the rather cryptic
error message. Since `bin_read()' already had code to temporarily open
`SHTTY' again if it needed that, I have copied the code to
`bin_vared()'. But there we need a bit more, because `zrefresh()'
needs a correct `shout', where `correct' seems to mean that it has to
be a `FILE*' for the current `SHTTY'. So I made `bin_vared()' also
open/clode a local `shout'.
So, I'm never too sure when I hack such terminal code, but it seems to
work.
Bye
Sven
diff -u -r oldsrc/Zle/zle_main.c Src/Zle/zle_main.c
--- oldsrc/Zle/zle_main.c Mon Nov 8 12:46:10 1999
+++ Src/Zle/zle_main.c Mon Nov 8 13:23:29 1999
@@ -734,8 +734,9 @@
Value v;
Param pm = 0;
int create = 0;
- int type = PM_SCALAR, obreaks = breaks;
+ int type = PM_SCALAR, obreaks = breaks, haso = 0;
char *p1 = NULL, *p2 = NULL;
+ FILE *oshout;
if (zleactive) {
zwarnnam(name, "ZLE cannot be used recursively (yet)", NULL, 0);
@@ -816,6 +817,17 @@
return 1;
}
+ if (SHTTY == -1) {
+ /* need to open /dev/tty specially */
+ if ((SHTTY = open("/dev/tty", O_RDWR|O_NOCTTY)) == -1) {
+ zerrnam(name, "can't access terminal", NULL, 0);
+ return 1;
+ }
+ oshout = shout;
+ init_shout();
+
+ haso = 1;
+ }
/* edit the parameter value */
PERMALLOC {
pushnode(bufstack, ztrdup(s));
@@ -823,6 +835,12 @@
varedarg = *args;
t = (char *) zleread(p1, p2, ops['h'] ? ZLRF_HISTORY : 0);
varedarg = ova;
+ if (haso) {
+ close(SHTTY);
+ fclose(shout);
+ shout = oshout;
+ SHTTY = -1;
+ }
if (!t || errflag) {
/* error in editing */
errflag = 0;
--
Sven Wischnowsky wischnow@xxxxxxxxxxxxxxxxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author